Actual Final Flashcards
IMPORTANT NOTE: Creating a File object DOES NOT create a corresponding file folder on your hard drive. (T!)
NOTE: No folder is created on the disk when this object is instantiated BUT…we could later actually create the directories on the disk by using methods such as mkdir() and mkdirs()
Using getParentFile()
File fileOne = new File(“C:/temp34/myFile.txt”); fileOne.getParentFile().mkdirs(); //this builds the temp34 folder //now call createNewFile() fileOne.createNewFile(); //creates the empty .txt file in temp 34
any exceptions of the UNCHECKED flavor the coder does not have to write any special code called “exception handling code” .
Options that are unchecked include the ArithmeticException and the ArrayIndexOutOfBoundsException.
CONCEPT: A delimiter is a block of character(s) that separates words. WE DO NOT PRINT OUT THE DELIMITER character(s)
it takes as an argument something called a regular expression, which is a pattern of a set of character(s) inside a set of square brackets that it either looks for or ignores, depending on how you set it up
Example: the regular expression [0-9]+ would be a delimiter that says “interpret any block of one or more digits as a delimiter and do not print it to the screen”.
Example 2: in the regular expression[^0-9]+, the “^” caret symbol would mean “DO NOT include any digits in the delimiter” , but ALL OTHER CHARACTERS would be considered to be part of the delimiter, so they would not be printed.
One way to create a PrintWriter object is to call its constructor and pass it a file name: File
File myFile = new File(“output.txt”); Printwriter writer = new PrintWriter(myFile);