亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? bluetoothconnection.java

?? 手機藍牙驅動和應用實例源碼
?? JAVA
字號:
// Copyright 2004 Nokia Corporation.
//
// THIS SOURCE CODE IS PROVIDED 'AS IS', WITH NO WARRANTIES WHATSOEVER,
// EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY, FITNESS
// FOR ANY PARTICULAR PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE
// OR TRADE PRACTICE, RELATING TO THE SOURCE CODE OR ANY WARRANTY OTHERWISE
// ARISING OUT OF ANY PROPOSAL, SPECIFICATION, OR SAMPLE AND WITH NO
// OBLIGATION OF NOKIA TO PROVIDE THE LICENSEE WITH ANY MAINTENANCE OR
// SUPPORT. FURTHERMORE, NOKIA MAKES NO WARRANTY THAT EXERCISE OF THE
// RIGHTS GRANTED HEREUNDER DOES NOT INFRINGE OR MAY NOT CAUSE INFRINGEMENT
// OF ANY PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OWNED OR CONTROLLED
// BY THIRD PARTIES
//
// Furthermore, information provided in this source code is preliminary,
// and may be changed substantially prior to final release. Nokia Corporation
// retains the right to make changes to this source code at
// any time, without notice. This source code is provided for informational
// purposes only.
//
// Nokia and Nokia Connecting People are registered trademarks of Nokia
// Corporation.
// Java and all Java-based marks are trademarks or registered trademarks of
// Sun Microsystems, Inc.
// Other product and company names mentioned herein may be trademarks or
// trade names of their respective owners.
//
// A non-exclusive, non-transferable, worldwide, limited license is hereby
// granted to the Licensee to download, print, reproduce and modify the
// source code. The licensee has the right to market, sell, distribute and
// make available the source code in original or modified form only when
// incorporated into the programs developed by the Licensee. No other
// license, express or implied, by estoppel or otherwise, to any other
// intellectual property rights is granted herein.



//==============================================================================
// Package Statements



//==============================================================================
// Import Statements

//#ifndef useBT
//public class BluetoothConnection
//{
//}

//#else

import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.io.*;
import java.util.*;
import javax.bluetooth.*;


//==============================================================================
// CLASS (OR INTERFACE) DECLARATIONS

/** The <code>BluetoothConnection</code> encapsulates the Stream Input and
 * Output connections.
 * A BluetoothConnection is returned by
 * {@link BluetoothDiscovery#searchService BluetoothDiscovery.searchService} or
 * {@link BluetoothDiscovery#waitOnConnection BluetoothDiscovery.waitOnConnection}.
 */

public class BluetoothConnection
{

    //==============================================================================
    // Final variables (Class constants)

    //==============================================================================
    // Class (static) variables

    //==============================================================================
    // Instance variables
    private StreamConnection streamConnection;
    /** This is the InputStream associated with the Bluetooth Connection.
     */
    private InputStream inputStream;
    /** This is the OutputStream associated with the Bluetooth Connection.
     */
    private OutputStream outputStream;
    /** This is the name of the local device associated with the Bluetooth Connection.
     */
    private String localName;     // Name of local device for this connection
    /** This is the name of the remote device associated with the Bluetooth Connection.
     */
    private String remoteName;    // Name of remote device for this connection
    private String url; // urlStrings used for connecting, for server this is empty.



    //==============================================================================
    // Constructors and miscellaneous (finalize method, initialization block,...)

    /** Creates an <code>BluetoothConnection</code> object.
     * An Input- and an OutputStream is opened.
     * This constructor is used for mobile terminated connections (local device = server).
     * The connection object already exists and is passed as parameter.
     * @param con The StreamConnection object.
     * @param ln Name of local device for the connection. This is typically a friendly
     * name for the device.
     * @param rn Name of remote device for the connection. This is typically the service name or eg. the
     * friendly name of the remote device.
     * @param notif The notifier that has been used to create the StreamConenction object con. Is only used in Close(): the notifier is closed as well.
     */
    public BluetoothConnection(StreamConnection con, String ln, String rn)
        throws IOException
    {
        // Store name
        localName = ln;
        remoteName = rn;

        // Init url to zero
        url = "";

        // Store stream connection
        streamConnection = con;

        // Open Input and Output Streams
        openStreams();
    }

    /** Creates an <code>BluetoothConnection</code> object.
     * An Input- and an OutputStream is opened.
     * This constructor is used for mobile originated connections (local device = client).
     * A url is given as parameter and the constructor creates a connection.
     * @param urlStrings If local device = client then this is the url it connected to.
     * If local device = server then it is empty.
     * @param ln Name of local device for the connection. This is typically a friendly
     * name for the device.
     * @param rn Name of remote device for the connection. This is typically the service name or eg. the
     * friendly name of the remote device.
     * @throws IOException Signals that an I/O exception of some sort has occurred. This class is the general class of exceptions produced by failed or interrupted I/O operations.
     */
    public BluetoothConnection(String urlStrings, String ln, String rn)
        throws IOException
    {
        // Store name
        localName = ln;
        remoteName = rn;

        // Store the url
        url = urlStrings;

        // Connect to url
        connect();
    }   /*  End of the constructor method   */

    /**
     * Connects to url. Can only be used if url String is available, ie.
     * 'BluetoothConnection' was created with constructor
     * 'BluetoothConnection( String urlStrings, String ln, String rn )'.
     * This method is public. So, in case the link was disconnected (or link
     * was lost) this method can be used also to reconnect. Normally this method
     * is already called from the constructor.
     * @throws IOException Signals that an I/O exception of some sort has
     * occurred. This class is the general class of exceptions produced by
     * failed or interrupted I/O operations.
     */
    private void connect()
        throws IOException
    {
        // Create stream connection
        streamConnection = (StreamConnection) Connector.open( url );

        // Open Input and Output Streams
        openStreams();
    }

    /**
     * Opens the InputStream and the OutputStream for the
     * StreamConnection object (streamConnection)
     */
    private void openStreams()
        throws IOException
    {
        inputStream = streamConnection.openInputStream();
        outputStream = streamConnection.openOutputStream();
    }

    /**
     * Closes all connections.
     */
    synchronized public void close()
    {
        try
        {
            outputStream.close();
        }
        catch(IOException e)
        {
            // There is not much we can do; we tried to close it.
        }

        try
        {
            inputStream.close();
        }
        catch(IOException e)
        {
            // There is not much we can do; we tried to close it.
        }

        try
        {
            if(streamConnection != null)
            {
                streamConnection.close();
                streamConnection = null;
            }
        }
        catch( IOException e )
        {
            // There is not much we can do; we tried to close it.
        }
    }

    public InputStream getInputStream()
    {
        return inputStream;
    }

    public OutputStream getOutputStream()
    {
        return outputStream;
    }

    public String getLocalName()
    {
        return localName;
    }

    public String getRemoteName()
    {
        return remoteName;
    }

    /** Sets a remote name for this Connection.
     * Is used by {@link BluetoothDiscovery BluetoothDiscovery}.
     * @param rn The remote name to be used for this connection.
     */
    protected void setRemoteName( String rn )
    {
        remoteName = rn;
    }

    /** Sends a string to remote device.
     * It first sends the length (int), followed by the characters.
     * String is not null-terminated.
     * String is sent directly to remote device (flushed).
     * Strings have to be limited to 255 chars max.
     * Is used by {@link BluetoothDiscovery BluetoothDiscovery}.
     * @param s String to be send to remote device.
     */
    public void writeString(String s)
        throws IOException
    {
        // Convert to byte array
        byte[] bytes = s.getBytes();
        // Length
        outputStream.write(bytes.length); // Writes only the low-order byte of length
        // String
        outputStream.write(bytes);
        // Flush
        outputStream.flush();
    }

    /** Reads a string from remote device.
     * It first reads the length (int), followed by the characters.
     * String is not null-terminated.
     * Strings have to be limited to 255 chars max.
     * Is used by {@link BluetoothDiscovery BluetoothDiscovery}.
     * @return String that is read from the remote device.
     */
    public String readString()
        throws IOException
    {
        // Length
        int length = inputStream.read();
        byte[] bytes = new byte[length];
        read(bytes, length);

        return new String(bytes);
    }

    /**
     * Writes an integer
     */
    public void writeInt( int v )
    throws IOException
    {
        outputStream.write( (v & 0xFF) );
        outputStream.write( ((v>>8) & 0xFF) );
        outputStream.write( ((v>>16) & 0xFF) );
        outputStream.write( ((v>>24) & 0xFF) );
        // Flush
        outputStream.flush();
    }

    /**
     * Reads an integer
     */
    public int readInt()
    throws IOException
    {
        int res;

        res = inputStream.read();
        res += inputStream.read()<<8;
        res += inputStream.read()<<16;
        res += inputStream.read()<<24;
        return res;
    }

    /** Returns true if connection has been closed.
     * @return true if connection is closed, false if connection is open.
     */
    public boolean isClosed()
    {
        if( streamConnection == null )
        {
            // is closed
            return true;
        }
        else
        {
            // is still open
            return false;
        }
    }

    /** Reads bytes into the array. Blocks until 'len' bytes are read.
     * @param arr Array that should get the data.
     * @param len Number of bytes to read. Method doesn't return until all
     * bytes are read.
     */
    public void read( byte[] arr, int len )
    throws IOException
    {
        int offs, count;

        offs = 0;
        while( len > 0 )
        {
            // If still not all bytes read
            count = inputStream.read( arr, offs, len );
            len -= count;
            offs += count;
        }
    }
}
//#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
美女视频黄 久久| 成人午夜免费av| 国产成人精品一区二区三区网站观看| www.av亚洲| 精品国精品自拍自在线| 亚洲欧洲av在线| 久久er精品视频| 欧美性做爰猛烈叫床潮| 亚洲国产经典视频| 韩国av一区二区三区在线观看| 欧美日韩久久久| 亚洲精品中文字幕乱码三区| 国产成人av一区二区| 欧美精选午夜久久久乱码6080| 国产精品免费观看视频| 经典三级视频一区| 日韩一区二区电影在线| 亚洲激情自拍偷拍| 99re66热这里只有精品3直播 | 欧美亚洲国产一区二区三区va| 26uuu国产电影一区二区| 亚洲成人一区二区| 91福利社在线观看| 1024精品合集| 一本色道亚洲精品aⅴ| 国产欧美精品一区二区色综合 | 成人在线视频首页| 久久理论电影网| 国产原创一区二区| 精品国产区一区| 麻豆精品视频在线观看免费 | 日韩欧美成人激情| 日韩高清在线不卡| 日韩一级视频免费观看在线| 性久久久久久久| 91精品国产综合久久香蕉麻豆| 亚洲一区二三区| 在线免费观看日本欧美| 亚洲欧美区自拍先锋| 91网站在线观看视频| 亚洲欧洲日韩在线| 99国产精品99久久久久久| 欧美高清在线视频| 色综合久久天天综合网| 亚洲午夜影视影院在线观看| 欧洲亚洲精品在线| 午夜影院在线观看欧美| 7777精品伊人久久久大香线蕉| 亚洲国产裸拍裸体视频在线观看乱了| 在线观看www91| 日韩成人伦理电影在线观看| 欧美电影免费观看高清完整版在线观看| 蜜臀av性久久久久蜜臀av麻豆| 欧美精品一区视频| 国产福利不卡视频| 亚洲欧洲中文日韩久久av乱码| 欧美在线不卡视频| 日本视频免费一区| 国产网站一区二区| 色综合天天综合在线视频| 亚洲成人免费影院| 2024国产精品| 在线中文字幕一区| 美女mm1313爽爽久久久蜜臀| 中文一区一区三区高中清不卡| 日本高清不卡在线观看| 免费观看久久久4p| 中文字幕在线播放不卡一区| 欧美高清视频在线高清观看mv色露露十八| 久久精品国产一区二区三区免费看| 国产视频一区二区在线| 在线观看免费成人| 国产又黄又大久久| 亚洲国产精品久久久久秋霞影院| 精品国产亚洲一区二区三区在线观看| av中文一区二区三区| 首页国产欧美久久| 国产精品久久国产精麻豆99网站| 欧美喷潮久久久xxxxx| 高清在线不卡av| 五月婷婷另类国产| 国产精品白丝在线| 日韩一区二区在线播放| 色婷婷综合久久久中文一区二区| 精品影院一区二区久久久| 玉足女爽爽91| 国产精品污www在线观看| 欧美一区午夜精品| 99riav一区二区三区| 国产九色sp调教91| 蜜桃91丨九色丨蝌蚪91桃色| 国产精品传媒入口麻豆| 久久综合一区二区| 91麻豆精品国产自产在线观看一区| 99精品热视频| 国产不卡视频一区二区三区| 美女性感视频久久| 亚洲午夜久久久久| 亚洲女人的天堂| 久久人人爽爽爽人久久久| 7777精品久久久大香线蕉| 在线视频一区二区三区| 97久久精品人人做人人爽| 国产精品综合一区二区| 久热成人在线视频| 日本成人在线电影网| 亚洲国产日日夜夜| 亚洲男人的天堂一区二区| 国产欧美日韩卡一| 26uuu国产在线精品一区二区| 91精品国产一区二区人妖| 精品视频在线看| 91网上在线视频| 91丨porny丨国产| 99久久免费视频.com| 成人丝袜18视频在线观看| 成人性视频免费网站| 国产丶欧美丶日本不卡视频| 国产一区二区精品久久99| 国产成人午夜99999| 国产精品123| 成人av资源在线观看| 成人精品视频网站| 色综合久久99| 欧美唯美清纯偷拍| 欧美二区在线观看| 欧美一区二区免费视频| 欧美成人性战久久| 精品福利视频一区二区三区| 久久夜色精品国产欧美乱极品| 久久九九国产精品| 日韩一区日韩二区| 亚洲福利一区二区三区| 肉色丝袜一区二区| 国产一区999| 成人精品国产福利| 欧洲精品在线观看| 欧美一区二区三区视频在线 | 麻豆91免费看| 国产成人高清在线| 日本乱码高清不卡字幕| 8x福利精品第一导航| 日韩久久久精品| 国产精品午夜久久| 午夜影院在线观看欧美| 韩国v欧美v日本v亚洲v| fc2成人免费人成在线观看播放| 91蜜桃在线观看| 日韩一级免费一区| 国产精品毛片久久久久久久| 怡红院av一区二区三区| 免费在线欧美视频| 99这里只有精品| 欧美高清精品3d| 欧美国产精品专区| 亚洲动漫第一页| 国产精品伊人色| 欧洲一区在线电影| 久久久精品欧美丰满| 亚洲v中文字幕| 成人免费av网站| 91超碰这里只有精品国产| 中文字幕第一页久久| 日本不卡一区二区三区高清视频| 高清成人免费视频| 欧美精品777| 亚洲人成精品久久久久久| 韩国中文字幕2020精品| 精品婷婷伊人一区三区三| 欧美激情一区二区| 全国精品久久少妇| 日本高清视频一区二区| 国产校园另类小说区| 日韩电影免费在线观看网站| www.日韩在线| 日韩欧美一卡二卡| 亚洲精品视频免费看| 成人毛片在线观看| 日韩美女一区二区三区四区| 亚洲午夜一区二区三区| 91在线观看视频| 国产欧美一区二区精品忘忧草| 视频一区二区中文字幕| 91福利国产精品| 亚洲欧美日韩电影| 成人美女视频在线看| 久久久久久久久岛国免费| 蜜桃一区二区三区在线| 欧美日韩性生活| 一区二区不卡在线视频 午夜欧美不卡在| 精品一区二区成人精品| 欧美一区二区三区免费在线看| 一区二区三区欧美| 国产91高潮流白浆在线麻豆| 精品国产乱码久久久久久闺蜜| 日本视频一区二区三区| 欧美一区二区三区思思人| 人人超碰91尤物精品国产| 91精品国产高清一区二区三区蜜臀 | 国产精品全国免费观看高清|