Advertisement
karbaev

Untitled

Oct 14th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. class ReadBytesFromFile {
  4. public static void main(String args[]) throws Exception {
  5. File file;
  6. FileInputStream fileStream = new FileInputStream(file = new File("test.txt"));
  7.  
  8. byte[] arr = new byte[(int) file.length()];
  9.  
  10. //чтение
  11. fileStream.read(arr, 0, arr.length);
  12.  
  13. //вывод
  14. for (int X : arr) {
  15. System.out.print((char) X);
  16. }
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement