⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 obexmanager.java

📁 GPS Track connects to a GPS and records the path that you travel. Tracks can be uploaded to a web s
💻 JAVA
字号:
// J2ME GPS Track
// Copyright (C) 2007 Dana Peters
// http://www.qcontinuum.org/gpstrack

package org.qcontinuum.gpstrack;

import java.io.*;
import javax.microedition.io.*;
import javax.obex.*;

// optional package wrapper class
// technique described in Chapter 8 of JSR 248

public class ObexManager implements ObexUsage {
    
    ClientSession mClientSession = null;
    Operation mOperation = null;

    public ObexManager() {
    }
    
    public DataOutputStream open(String url, String filename) throws IOException {
        try {
            mClientSession = (ClientSession)Connector.open(url);
        } catch (ConnectionNotFoundException ex) {
            mClientSession = (ClientSession)de.avetana.obexsolo.OBEXConnector.open(url);
        }
        HeaderSet headerSet = mClientSession.connect(mClientSession.createHeaderSet());
        headerSet.setHeader(HeaderSet.NAME, filename);
        headerSet.setHeader(HeaderSet.TYPE, "text");
        mOperation = mClientSession.put(headerSet);
        return mOperation.openDataOutputStream();
    }
    
    public void close() throws IOException {
        if (mOperation != null)
            mOperation.close();
        if (mClientSession != null) {
            mClientSession.disconnect(null);
            mClientSession.close();
        }
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -