Advertisement
jaVer404

level18.lesson05.task05_half_done

Nov 4th, 2015
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 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.         boolean flag = false;
  20.         while (!flag) {
  21.             fileName=reader.readLine();
  22.             int fileSize = (int)new File(fileName).length();
  23.             if (fileSize<1000 ) {
  24.                 flag=true;
  25.                 throw new DownloadException();
  26.             }
  27.             reader.close();
  28.         }
  29.     }
  30.  
  31.     public static class DownloadException extends Exception{
  32.  
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement