Advertisement
Strade351

Pr4

Aug 30th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import java.io.*;
  2. import java.nio.BufferOverflowException;
  3.  
  4. /**
  5. * Created by Anatoliy on 31.08.2016.
  6. * Pr 4.1
  7. */
  8. public class Pr4 {
  9. public static void main(String[] args) throws FileNotFoundException {
  10. String filename = "MyFile.txt";
  11. File file = new File(filename);
  12. try (FileReader reader = new FileReader(file))
  13. {
  14. char[] buffer = new char[(int)file.length()];
  15. reader.read(buffer);
  16. System.out.println(new String(buffer));
  17. }
  18. catch (IOException ex) {
  19. System.out.println(ex.getMessage());
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement