本文整理汇总了Java中javax.microedition.io.StreamConnection.openDataOutputStream方法的典型用法代码示例。如果您正苦于以下问题:Java StreamConnection.openDataOutputStream方法的具体用法?Java StreamConnection.openDataOutputStream怎么用?Java StreamConnection.openDataOutputStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.microedition.io.StreamConnection
的用法示例。
在下文中一共展示了StreamConnection.openDataOutputStream方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.microedition.io.StreamConnection; //导入方法依赖的package包/类
public static void main(String[] args) {
// Default to indicate error
int returnCode = -1;
try {
StreamConnection connection = (StreamConnection) Connector.open("uei:");
DataOutputStream out = connection.openDataOutputStream();
out.writeInt(args.length);
for (int i=0; i < args.length; i++) {
out.writeUTF(args[i]);
}
out.close();
InputStream in = connection.openInputStream();
returnCode = in.read();
in.close();
} catch (Throwable t) {
t.printStackTrace();
} finally {
System.exit(returnCode);
}
}
示例2: processConnection
import javax.microedition.io.StreamConnection; //导入方法依赖的package包/类
/**
* Let the event listener process the connection.
*/
private void processConnection(StreamConnection conn) {
DataOutputStream dos = null;
DataInputStream dis = null;
try{
dos = new DataOutputStream(conn.openDataOutputStream());
dis = new DataInputStream(conn.openDataInputStream());
this.eventListener.processConnection(dis, dos);
}catch(IOException e){
raiseError("Error getting data stream",e);
}
}
示例3: openConnection
import javax.microedition.io.StreamConnection; //导入方法依赖的package包/类
public boolean openConnection(String destIpAddr, String destPort) {
address = "socket://" + destIpAddr + ":" + destPort;
try {
conn = (StreamConnection) Connector.open(address);
outStream = new OutputStreamWriter(conn.openDataOutputStream());
} catch (Throwable e) {
System.out.println("Logger connection open exception: " + e.toString() + " to: " + address);
return false;
}
return true;
}
示例4: updateConfig
import javax.microedition.io.StreamConnection; //导入方法依赖的package包/类
public boolean updateConfig(String destIpAddr, String destPort) {
address = "socket://" + destIpAddr + ":" + destPort;
closeConnection();
try {
conn = (StreamConnection) Connector.open(address);
outStream = new OutputStreamWriter(conn.openDataOutputStream());
} catch (Throwable e) {
return false;
}
return true;
}