Code example for DataInputStream

Methods: available, readFully, readInt

0
	 * Check if we have data to process 
	 */ 
	void checkForData() { 
		try { 
			// If there is no data, then check the keep alive timeout 
			if (mIn.available() == 0) {
				checkKeepAlive(); 
			} else { 
				// Otherwise read the data and parse it 
				int len = mIn.readInt();
				byte[] data = new byte[len];
				mIn.readFully(data, 0, len);
				processProtocolBuffer(data);
			} 
		} catch (IOException e) {
			sendUiMessage(new InvalidData()); 
		} 
		 
		// Let the looper send the message again 
		if (App.mClementine.isConnected()) { 
			Message msg = Message.obtain();