Created
January 30, 2017 19:23
-
-
Save codyhex/a6883cd71e498db1f01baec830c2c652 to your computer and use it in GitHub Desktop.
Read the bytes from input stream to fill the buffer array size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example; | |
import java.io.IOException; | |
import java.util.Arrays; | |
class MyTestClass | |
{ | |
public static void main(String[] args){ | |
byte[] bytes = new byte[30]; | |
try { | |
System.out.println("Available bytes :"+System.in.available()); | |
System.out.print("Write something :"); | |
int bytesread = System.in.read(bytes); | |
System.out.println("I've read :"+bytesread +" bytes from the InputStream"); | |
System.out.println(Arrays.toString(bytes)); | |
} catch (IOException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment