InputStream inputStream = new FileInputStream("file.txt"); if(inputStream.available() != 0) { // Read data from the input stream }
InputStream inputStream = socket.getInputStream(); while(inputStream.available() == 0) { // Wait for data to become available } // Read data from the input streamThis example creates an input stream from a socket connection and waits until data becomes available. Package library: java.io