Advertisement
jaVer404

level18.lesson05.task05_done

Nov 4th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. package com.javarush.test.level18.lesson05.task05;
  2.  
  3. /* DownloadException
  4. 1 Считывать с консоли имена файлов.
  5. 2 Если файл меньше 1000 байт, то:
  6. 2.1 Закрыть потоки
  7. 2.2 выбросить исключение DownloadException
  8. */
  9.  
  10. import java.io.BufferedReader;
  11. import java.io.File;
  12. import java.io.IOException;
  13. import java.io.InputStreamReader;
  14.  
  15. public class Solution {
  16.     public static void main(String[] args) throws DownloadException, IOException {
  17.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  18.         String fileName;
  19.         while (true) {
  20.             fileName=reader.readLine();
  21.             int fileSize = (int)new File(fileName).length();
  22.             if (fileSize<1000 ) {
  23.                 reader.close();
  24.                 throw new DownloadException();
  25.             }
  26.         }
  27.     }
  28.  
  29.     public static class DownloadException extends Exception{
  30.  
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement