Hello, I am having a hard time understanding this logic. I need to create a file named javaprogramming.txt. This file should be stored in the following directory: c:\data\java\it215. If the directory does not exist it should be created. If the file and or directory cannot be created for any reason the following message should be displayed to the user: “An error occurred creating javaprogramming.txt. Please contact your System Administrator.”
First, since java is case sensitive I thought we had to save our files as JavaProgramming rather then javaprogramming (uppercase not lowercase)? Then if I save a file under .txt it won't be a program just a txt. Im so confused on the logic of this question. I am sure I am over thinking it but I still don't get it. I did do my reasearch and come up with lots of websites but no help. I have seen several different examples but not sure I get the point of the logic in the question I guess.
import java.io.File;
Now, I also have seen the try and catch statements too which I thought would be key in what I am trying to do. Then as I read on and found in my "Java for Dummies" book and there are different examples. Then I also thought maybe it would look like this:public class ListFiles { public static void main(String[] args) { // Directory path here String path = ""; String files; File folder = new File(path); File[] listOfFiles = folder.listFiles(new MyFilter()); for (int i = 0; i < listOfFiles.length; i++) { System.out.println(listOfFiles[i].getName()); } } }Can anyone help me understand the logic behind the question above so that I can understand this? Why would we ever want to add a directory name to a file name in java anyway? I very confused.if (!createPath( path )) System.out.println( "Failed to create path " + path ); public boolean createPath( string path ) { File filePath = File( path ); if (!filePath.exists()) //if the dirs do not exist try { filePath.mkdirs(); } catch( SecurityException ) { return false } return true; }