Hello kind of hung up on a part of my code and was wondering if anyone could help me out
i need to use a try catch to insure that the input file is correct/available
public class tempProgram
* @param args
public static void main(String args) throws FileNotFoundException
Scanner console = new Scanner(System.in);
String inputFileName = "";
System.out.print("Please enter file name");
inputFileName = console.next();
File inputFile = new File(inputFileName);
Scanner in = new Scanner(inputFile);
PrintWriter out = new PrintWriter("outputFileName.txt");
i tried a couple different ways to do it but each time i tried it failed really badly and i confused myself, if seeing all of the code would be of help to anyone just let me know.
Re: Weather Program
Best practices are to enclose only the code that can throw an exception with a try/catch statement. The first thing you need to do is identify what lines of code may throw exceptions. Reading the API will help or the lazy way is to just compile your code and the compiler will tell you (as long as you delete the throws clause on the main method).