Created
July 13, 2016 15:34
-
-
Save josinSbazin/4fe176af401c8a65230ad599dea95835 to your computer and use it in GitHub Desktop.
level18.lesson10.home09
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.lesson10.home09; | |
/* Файлы и исключения | |
Читайте с консоли имена файлов | |
Если файла не существует (передано неправильное имя файла), то | |
перехватить исключение FileNotFoundException, вывести в консоль переданное неправильное имя файла и завершить работу | |
программы. | |
Закрыть потоки. Не использовать try-with-resources | |
Не используйте System.exit(); | |
*/ | |
import java.io.*; | |
public class Solution { | |
public static void main(String[] args) { | |
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); | |
FileInputStream fis = null; | |
String name = new String(); | |
try { | |
while (true) { | |
name = reader.readLine(); | |
fis = new FileInputStream(name); | |
} | |
} catch (FileNotFoundException e) { | |
System.out.print(name); | |
} | |
catch (IOException ignore) {/*NOP*/} | |
finally { | |
try { | |
if (fis!=null) fis.close(); | |
reader.close(); | |
} catch (IOException ignore) {/*NOP*/} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment