Java Code Examples for javax.microedition.io.StreamConnection#openInputStream()
The following examples show how to use
javax.microedition.io.StreamConnection#openInputStream() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JmeIoLib.java From luaj with MIT License | 6 votes |
protected File openFile( String filename, boolean readMode, boolean appendMode, boolean updateMode, boolean binaryMode ) throws IOException { String url = "file:///" + filename; int mode = readMode? Connector.READ: Connector.READ_WRITE; StreamConnection conn = (StreamConnection) Connector.open( url, mode ); File f = readMode? new FileImpl(conn, conn.openInputStream(), null): new FileImpl(conn, conn.openInputStream(), conn.openOutputStream()); /* if ( appendMode ) { f.seek("end",0); } else { if ( ! readMode ) conn.truncate(0); } */ return f; }
Example 2
Source File: TestSSLStreamConnection.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
void testBasicSSLStreamConnection() throws IOException { StreamConnection t = (StreamConnection)Connector.open(SOCKET_URL); try { SSLStreamConnection s = new SSLStreamConnection(HOST, PORT, t.openInputStream(), t.openOutputStream(), KEY_STORE); OutputStream os = s.openOutputStream(); InputStream is = s.openInputStream(); send(os, MESSAGE); th.check(receive(is), MESSAGE); os.close(); is.close(); s.close(); } finally { t.close(); } }
Example 3
Source File: TestSSLStreamConnection.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
void testMultipleSendsReceivesOnSameSocket() throws IOException { StreamConnection t = (StreamConnection)Connector.open(SOCKET_URL); try { SSLStreamConnection s = new SSLStreamConnection(HOST, PORT, t.openInputStream(), t.openOutputStream(), KEY_STORE); OutputStream os = s.openOutputStream(); InputStream is = s.openInputStream(); for (int i = 0; i < 100; i++) { String message = "Message n." + i; send(os, message); th.check(receive(is), message); } os.close(); is.close(); s.close(); } finally { t.close(); } }
Example 4
Source File: TestSSLStreamConnection.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
void testMultipleSendsReceivesOnMultipleSockets() throws IOException { for (int i = 0; i < 100; i++) { StreamConnection t = (StreamConnection)Connector.open(SOCKET_URL); try { SSLStreamConnection s = new SSLStreamConnection(HOST, PORT, t.openInputStream(), t.openOutputStream(), KEY_STORE); OutputStream os = s.openOutputStream(); InputStream is = s.openInputStream(); String message = "Message n." + i; send(os, message); th.check(receive(is), message); os.close(); is.close(); s.close(); } finally { t.close(); } } }
Example 5
Source File: TestSSLStreamConnection.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
void testSendOnClosedOutputStream() throws IOException { StreamConnection t = (StreamConnection)Connector.open(SOCKET_URL); try { SSLStreamConnection s = new SSLStreamConnection(HOST, PORT, t.openInputStream(), t.openOutputStream(), KEY_STORE); OutputStream os = s.openOutputStream(); InputStream is = s.openInputStream(); os.close(); try { send(os, MESSAGE); th.fail("send on closed output stream"); } catch(Exception e) { th.check(e, "java.io.InterruptedIOException: Stream closed"); } is.close(); s.close(); } finally { t.close(); } }
Example 6
Source File: TestSSLStreamConnection.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
void testReceiveOnClosedInputStream() throws IOException { StreamConnection t = (StreamConnection)Connector.open(SOCKET_URL); try { SSLStreamConnection s = new SSLStreamConnection(HOST, PORT, t.openInputStream(), t.openOutputStream(), KEY_STORE); OutputStream os = s.openOutputStream(); InputStream is = s.openInputStream(); send(os, MESSAGE); is.close(); try { receive(is); th.fail("receive on closed input stream"); } catch(Exception e) { th.check(e, "java.io.InterruptedIOException: Stream closed"); } os.close(); s.close(); } finally { t.close(); } }
Example 7
Source File: BTGOEPConnection.java From pluotsorbet with GNU General Public License v2.0 | 4 votes |
protected BTGOEPConnection(StreamConnection sock) throws IOException { this.sock = sock; is = sock.openInputStream(); os = sock.openOutputStream(); }