Created
July 8, 2016 17:28
-
-
Save josinSbazin/a54dad5d28bc1a21074e87afc624eda4 to your computer and use it in GitHub Desktop.
level18.lesson05.task05
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level18.lesson05.task05; | |
/* DownloadException | |
1 Считывать с консоли имена файлов. | |
2 Если файл меньше 1000 байт, то: | |
2.1 Закрыть потоки | |
2.2 выбросить исключение DownloadException | |
*/ | |
import java.io.BufferedReader; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
public class Solution { | |
public static void main(String[] args) throws DownloadException, IOException { | |
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); | |
FileInputStream stream; | |
boolean wtf = true; | |
String fileName; | |
while (wtf) { | |
fileName = reader.readLine(); | |
stream = new FileInputStream(fileName); | |
wtf = stream.available() > 1000 ? true:false; | |
stream.close(); | |
} | |
reader.close(); | |
throw new DownloadException(); | |
} | |
public static class DownloadException extends Exception{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment