Advertisement
jaVer404

level13.lesson11.home03

May 20th, 2015
493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. package com.javarush.test.level13.lesson11.home03;
  2.  
  3. /* Чтение файла
  4. 1. Считать с консоли имя файла.
  5. 2. Вывести в консоль(на экран) содержимое файла.
  6. 3. Не забыть закрыть файл и поток.
  7. */
  8.  
  9. import java.io.*;
  10.  
  11. public class Solution
  12. {
  13.     public static void main(String[] args)throws IOException
  14.     {
  15.         //add your code here
  16.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  17.         String fileName = reader.readLine();
  18.         InputStream inputStream = new FileInputStream(fileName);
  19.         while (inputStream.available()>0) {
  20.             int data = inputStream.read();
  21.             System.out.print((char)data);
  22.         }
  23.         inputStream.close();
  24.         reader.close();
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement