Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javarush.test.level18.lesson05.task05;
- /* DownloadException
- 1 Считывать с консоли имена файлов.
- 2 Если файл меньше 1000 байт, то:
- 2.1 Закрыть потоки
- 2.2 выбросить исключение DownloadException
- */
- import java.io.BufferedReader;
- import java.io.File;
- 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));
- String fileName;
- while (true) {
- fileName=reader.readLine();
- int fileSize = (int)new File(fileName).length();
- if (fileSize<1000 ) {
- reader.close();
- throw new DownloadException();
- }
- }
- }
- public static class DownloadException extends Exception{
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement