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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? btimageserver.java

?? 手機(jī)藍(lán)牙通信程序
?? JAVA
字號(hào):
/* * * Copyright (c) 2007, Sun Microsystems, Inc. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * *  * Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. *  * Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. *  * Neither the name of Sun Microsystems nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */package example.bluetooth.demo;import java.io.ByteArrayOutputStream;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.util.Hashtable;import java.util.Vector;// jsr082 APIimport javax.bluetooth.DataElement;import javax.bluetooth.DiscoveryAgent;import javax.bluetooth.LocalDevice;import javax.bluetooth.ServiceRecord;import javax.bluetooth.ServiceRegistrationException;import javax.bluetooth.UUID;// midp/cldc APIimport javax.microedition.io.Connector;import javax.microedition.io.StreamConnection;import javax.microedition.io.StreamConnectionNotifier;/** * Established the BT service, accepts connections * and send the requested image silently. * * @version , */final class BTImageServer implements Runnable {    /** Describes this server */    private static final UUID PICTURES_SERVER_UUID =        new UUID("F0E0D0C0B0A000908070605040302010", false);    /** The attribute id of the record item with images names. */    private static final int IMAGES_NAMES_ATTRIBUTE_ID = 0x4321;    /** Keeps the local device reference. */    private LocalDevice localDevice;    /** Accepts new connections. */    private StreamConnectionNotifier notifier;    /** Keeps the information about this server. */    private ServiceRecord record;    /** Keeps the parent reference to process specific actions. */    private GUIImageServer parent;    /** Becomes 'true' when this component is finalized. */    private boolean isClosed;    /** Creates notifier and accepts clients to be processed. */    private Thread accepterThread;    /** Process the particular client from queue. */    private ClientProcessor processor;    /** Optimization: keeps the table of data elements to be published. */    private final Hashtable dataElements = new Hashtable();    /**     * Constructs the bluetooth server, but it is initialized     * in the different thread to "avoid dead lock".     */    BTImageServer(GUIImageServer parent) {        this.parent = parent;        // we have to initialize a system in different thread...        accepterThread = new Thread(this);        accepterThread.start();    }    /**     * Accepts a new client and send him/her a requested image.     */    public void run() {        boolean isBTReady = false;        try {            // create/get a local device            localDevice = LocalDevice.getLocalDevice();            // set we are discoverable            if (!localDevice.setDiscoverable(DiscoveryAgent.GIAC)) {                // Some implementations always return false, even if                // setDiscoverable successful                // throw new IOException("Can't set discoverable mode...");            }            // prepare a URL to create a notifier            StringBuffer url = new StringBuffer("btspp://");            // indicate this is a server            url.append("localhost").append(':');            // add the UUID to identify this service            url.append(PICTURES_SERVER_UUID.toString());            // add the name for our service            url.append(";name=Picture Server");            // request all of the client not to be authorized            // some devices fail on authorize=true            url.append(";authorize=false");            // create notifier now            notifier = (StreamConnectionNotifier)Connector.open(url.toString());            // and remember the service record for the later updates            record = localDevice.getRecord(notifier);            // create a special attribute with images names            DataElement base = new DataElement(DataElement.DATSEQ);            record.setAttributeValue(IMAGES_NAMES_ATTRIBUTE_ID, base);            // remember we've reached this point.            isBTReady = true;        } catch (Exception e) {            System.err.println("Can't initialize bluetooth: " + e);        }        parent.completeInitialization(isBTReady);        // nothing to do if no bluetooth available        if (!isBTReady) {            return;        }        // ok, start processor now        processor = new ClientProcessor();        // ok, start accepting connections then        while (!isClosed) {            StreamConnection conn = null;            try {                conn = notifier.acceptAndOpen();            } catch (IOException e) {                // wrong client or interrupted - continue anyway                continue;            }            processor.addConnection(conn);        }    }    /**     * Updates the service record with the information     * about the published images availability.     * <p>     * This method is invoked after the caller has checked     * already that the real action should be done.     *     * @return true if record was updated successfully, false otherwise.     */    boolean changeImageInfo(String name, boolean isPublished) {        // ok, get the record from service        DataElement base = record.getAttributeValue(IMAGES_NAMES_ATTRIBUTE_ID);        // check the corresponding DataElement object is created already        DataElement de = (DataElement)dataElements.get(name);        // if no, then create a new DataElement that describes this image        if (de == null) {            de = new DataElement(DataElement.STRING, name);            dataElements.put(name, de);        }        // we know this data element has DATSEQ type        if (isPublished) {            base.addElement(de);        } else {            if (!base.removeElement(de)) {                System.err.println("Error: item was not removed for: " + name);                return false;            }        }        record.setAttributeValue(IMAGES_NAMES_ATTRIBUTE_ID, base);        try {            localDevice.updateRecord(record);        } catch (ServiceRegistrationException e) {            System.err.println("Can't update record now for: " + name);            return false;        }        return true;    }    /**     * Destroy a work with bluetooth - exits the accepting     * thread and close notifier.     */    void destroy() {        isClosed = true;        // finalize notifier work        if (notifier != null) {            try {                notifier.close();            } catch (IOException e) {            } // ignore        }        // wait for acceptor thread is done        try {            accepterThread.join();        } catch (InterruptedException e) {        } // ignore        // finalize processor        if (processor != null) {            processor.destroy(true);        }        processor = null;    }    /**     * Reads the image name from the specified connection     * and sends this image through this connection, then     * close it after all.     */    private void processConnection(StreamConnection conn) {        // read the image name first        String imgName = readImageName(conn);        // check this image is published and get the image file name        imgName = parent.getImageFileName(imgName);        // load image data into buffer to be send        byte[] imgData = getImageData(imgName);        // send image data now        sendImageData(imgData, conn);        // close connection and good-bye        try {            conn.close();        } catch (IOException e) {        } // ignore    }    /** Send image data. */    private void sendImageData(byte[] imgData, StreamConnection conn) {        if (imgData == null) {            return;        }        OutputStream out = null;        try {            out = conn.openOutputStream();            out.write(imgData.length >> 8);            out.write(imgData.length & 0xff);            out.write(imgData);            out.flush();        } catch (IOException e) {            System.err.println("Can't send image data: " + e);        }        // close output stream anyway        if (out != null) {            try {                out.close();            } catch (IOException e) {            } // ignore        }    }    /** Reads image name from specified connection. */    private String readImageName(StreamConnection conn) {        String imgName = null;        InputStream in = null;        try {            in = conn.openInputStream();            int length = in.read(); // 'name' length is 1 byte            if (length <= 0) {                throw new IOException("Can't read name length");            }            byte[] nameData = new byte[length];            length = 0;            while (length != nameData.length) {                int n = in.read(nameData, length, nameData.length - length);                if (n == -1) {                    throw new IOException("Can't read name data");                }                length += n;            }            imgName = new String(nameData);        } catch (IOException e) {            System.err.println(e);        }        // close input stream anyway        if (in != null) {            try {                in.close();            } catch (IOException e) {            } // ignore        }        return imgName;    }    /** Reads images data from MIDlet archive to array. */    private byte[] getImageData(String imgName) {        if (imgName == null) {            return null;        }        InputStream in = getClass().getResourceAsStream(imgName);        // read image data and create a byte array        byte[] buff = new byte[1024];        ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);        try {            while (true) {                int length = in.read(buff);                if (length == -1) {                    break;                }                baos.write(buff, 0, length);            }        } catch (IOException e) {            System.err.println("Can't get image data: imgName=" + imgName + " :" + e);            return null;        }        return baos.toByteArray();    }    /**     * Organizes the queue of clients to be processed,     * processes the clients one by one until destroyed.     */    private class ClientProcessor implements Runnable {        private Thread processorThread;        private Vector queue = new Vector();        private boolean isOk = true;        ClientProcessor() {            processorThread = new Thread(this);            processorThread.start();        }        public void run() {            while (!isClosed) {                // wait for new task to be processed                synchronized (this) {                    if (queue.size() == 0) {                        try {                            wait();                        } catch (InterruptedException e) {                            System.err.println("Unexpected exception: " + e);                            destroy(false);                            return;                        }                    }                }                // send the image to specified connection                StreamConnection conn;                synchronized (this) {                    // may be awaked by "destroy" method.                    if (isClosed) {                        return;                    }                    conn = (StreamConnection)queue.firstElement();                    queue.removeElementAt(0);                    processConnection(conn);                }            }        }        /** Adds the connection to queue and notifies the thread. */        void addConnection(StreamConnection conn) {            synchronized (this) {                queue.addElement(conn);                notify();            }        }        /** Closes the connections and . */        void destroy(boolean needJoin) {            StreamConnection conn;            synchronized (this) {                notify();                while (queue.size() != 0) {                    conn = (StreamConnection)queue.firstElement();                    queue.removeElementAt(0);                    try {                        conn.close();                    } catch (IOException e) {                    } // ignore                }            }            // wait until dispatching thread is done            try {                processorThread.join();            } catch (InterruptedException e) {            } // ignore        }    }} // end of class 'BTImageServer' definition

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区三区四区在线观看 | 91在线视频在线| 国产精品久久久久aaaa樱花| 精品一区二区三区的国产在线播放 | 国产在线麻豆精品观看| 精品一区二区三区欧美| 国产亚洲综合在线| 色综合久久综合中文综合网| 国产精品久久久久影院色老大| 精品国产一区二区国模嫣然| 91亚洲国产成人精品一区二三| 亚洲成人7777| 国产色产综合色产在线视频| 国产亚洲欧美在线| 欧美在线999| 亚洲精品一区在线观看| 欧美日韩国产中文| 91网站在线播放| 欧美白人最猛性xxxxx69交| 91精品国产综合久久精品| 欧美日韩久久久久久| 精品日产卡一卡二卡麻豆| 老鸭窝一区二区久久精品| 亚洲日本在线天堂| 亚洲免费av高清| 91精品福利视频| 欧美无砖专区一中文字| 天堂va蜜桃一区二区三区| 日本aⅴ亚洲精品中文乱码| 青青草原综合久久大伊人精品优势 | 国产精品羞羞答答xxdd| 美国十次了思思久久精品导航| 久久久亚洲国产美女国产盗摄| 亚洲综合免费观看高清完整版在线| 中文字幕av在线一区二区三区| 欧美日韩三级一区二区| 美女视频一区二区三区| 日日噜噜夜夜狠狠视频欧美人 | 69堂精品视频| 国产盗摄精品一区二区三区在线| 日韩精品1区2区3区| 国产亚洲视频系列| 欧美日韩精品一区二区天天拍小说 | 天天色图综合网| 69堂国产成人免费视频| 东方aⅴ免费观看久久av| 日韩中文字幕麻豆| 亚洲乱码一区二区三区在线观看| 亚洲日本免费电影| 亚洲精品国产无天堂网2021| 日韩欧美在线综合网| 亚洲一二三区视频在线观看| 亚洲美女一区二区三区| 91精品国产91久久综合桃花| 国产激情一区二区三区四区| 99re热这里只有精品免费视频 | 欧美一区欧美二区| 日韩一区二区三区免费看| 在线免费观看日韩欧美| 99久久精品免费看国产 | 美女www一区二区| 美女视频黄 久久| 国产九九视频一区二区三区| 欧美精品黑人性xxxx| 日韩精品一区二区三区视频播放 | 日本在线不卡一区| 中文字幕在线观看不卡视频| 婷婷成人激情在线网| 黄色资源网久久资源365| 日本不卡在线视频| 免费精品视频最新在线| 精品一区二区三区在线播放视频| 亚洲成av人片一区二区三区| 亚洲宅男天堂在线观看无病毒 | 国产精品女同一区二区三区| 国产精品乱子久久久久| 欧美最猛性xxxxx直播| 精品电影一区二区| 一区二区成人在线| 国产精品一区在线| 精品国产91乱码一区二区三区| 亚洲成人一区在线| 亚洲精品国产无天堂网2021| 日韩丝袜情趣美女图片| 亚洲天堂免费在线观看视频| 日韩国产欧美在线播放| 盗摄精品av一区二区三区| 久久久久久久网| 秋霞电影一区二区| 99久久综合色| 国产亚洲欧美日韩在线一区| 日韩成人伦理电影在线观看| 亚洲一区二区三区四区不卡| 欧美人妖巨大在线| 三级欧美在线一区| 精品国产sm最大网站免费看| 欧美性猛片aaaaaaa做受| 一区二区三区日韩| 丁香网亚洲国际| 亚洲福利国产精品| 亚洲一区在线观看免费| 精品久久久久久久久久久久久久久 | 韩国女主播一区| 天天色综合天天| 亚洲欧洲日韩综合一区二区| 成人免费视频播放| 蜜桃视频在线观看一区二区| 亚洲第一狼人社区| 久久久.com| 成人午夜激情在线| 蜜桃视频免费观看一区| 一区二区三区欧美| 亚洲欧美日韩久久| 99久久国产综合精品女不卡| 成人精品gif动图一区| 国产一区二区三区免费| 亚洲国产精品尤物yw在线观看| 欧美日韩高清一区二区三区| 欧美色老头old∨ideo| 91久久精品一区二区| 成人动漫一区二区三区| 亚洲卡通动漫在线| 日韩电影网1区2区| 日韩电影在线观看网站| 精彩视频一区二区三区| 欧美经典一区二区三区| 国产亚洲精品久| 亚洲男人天堂av| 亚洲成人免费在线| 欧美国产成人精品| 伊人性伊人情综合网| 精品一区二区三区欧美| 成人性生交大片免费看在线播放| 秋霞午夜av一区二区三区| 国产一区二区网址| 欧美理论在线播放| 久久久激情视频| 国产肉丝袜一区二区| 国产亚洲一区二区在线观看| 国模娜娜一区二区三区| 99麻豆久久久国产精品免费 | 精品一区二区三区日韩| 亚洲视频一区在线| 一区二区三区蜜桃网| 国产亚洲精品超碰| 亚洲丝袜另类动漫二区| 日日骚欧美日韩| 国产老肥熟一区二区三区| 久久成人精品无人区| 成人app网站| 97久久精品人人澡人人爽| 欧美不卡在线视频| 精品成人免费观看| 五月婷婷综合在线| 在线不卡一区二区| 亚洲成a人片在线观看中文| 亚洲国产乱码最新视频| 一区二区三区四区av| 日韩高清在线一区| 久久精品国产99国产精品| 成人听书哪个软件好| 欧美图区在线视频| 亚洲一区二区三区视频在线播放| 亚洲成人免费看| 精品免费国产二区三区 | 精品久久五月天| 中文字幕在线观看一区二区| 在线观看日韩精品| 国产精品乱码一区二区三区软件| 亚洲一区二区三区中文字幕| 色婷婷av一区二区三区之一色屋| 日韩视频一区二区三区| 六月丁香婷婷久久| 亚洲h在线观看| 欧美精品欧美精品系列| 欧美色精品在线视频| 亚洲一区二区三区中文字幕| 色激情天天射综合网| 亚洲人一二三区| 精品99999| 91香蕉视频在线| 久久国产精品免费| 欧美精选一区二区| 在线免费视频一区二区| 国产一区二区三区国产| 亚洲精品国产a久久久久久 | 91精选在线观看| 国产高清精品久久久久| 欧美国产一区在线| 欧美日韩国产小视频| 7777精品久久久大香线蕉| 色网综合在线观看| 色婷婷亚洲精品| 亚洲午夜精品17c| 亚洲精品免费视频| 视频在线观看一区二区三区| 一区二区在线观看不卡| 亚洲精品成人a在线观看| 欧美偷拍一区二区| 色婷婷久久久亚洲一区二区三区|