try-catch ブロックの後に宣言しようとしましたが、うまくいきs.next()
ません! s
try ブロック内にある場合にのみ、ドロップダウンが表示されます。
FNFE と IOE をスローしないため、Parsing 入力をひとまとめにしたり、適切なアクションをすべて try ブロックに入れたりしたくありません。ここで何ができますか?
public static void main(String[] args)
{
// TODO Auto-generated method stub
//Open file; file name specified in args (command line)
try{
FileReader freader = new FileReader(args[0]);
Scanner s = new Scanner(freader);
}catch(FileNotFoundException e){
System.err.println("Error: File not found. Exiting program...");
e.printStackTrace();
System.exit(-1);
}catch(IOException e){
System.err.println ("Error: IO exception. Exiting...");
e.printStackTrace();
System.exit(-1);
}
// if i try to declare s.next() here it would not work