Socket GetInputStream Example
Socket class GetInputStream example. This example shows you how to use GetInputStream method.
Socket class GetInputStream example. public InputStream getInputStream() throws IOException Returns an input stream for this socket. If this socket has an associated channel then the resulting input stream delegates all of its operations to the channel. If the channel is in non-blocking mode then the input stream's read operations will throw an IllegalBlockingModeException.
Here is the code
/*
* @ # GetInputStream.java
* A class representing use to getInputStream method
* of Socket class in java.net package
* version 19 June 2008
* author Rose India
*/
import java.net.*;
import java.io.*;
public class GetInputStream {
public static void main(String args[]) throws Exception {
Socket socket = new Socket();
//Connects this socket to the server.
socket.connect(new InetSocketAddress("192.168.10.80", 9090));
//return getInetAddress
InputStream iStream = socket.getInputStream();
System.out.println("available bytes " + iStream.available());
//close socket
socket.close();
}
} |
|