Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package StreamsFilesAndDirectories4;
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.util.Scanner;
- public class ReadFile {
- public static void main(String[] args) throws IOException {
- Scanner scanner = new Scanner(System.in);
- String path = "input.txt";
- try (InputStream fileInputStream = new FileInputStream(path)){
- int oneByte = fileInputStream.read();
- while (oneByte >= 0) {
- System.out.printf("%s ", Integer.toBinaryString(oneByte));
- oneByte = fileInputStream.read();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }finally {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment