Download presentation
Presentation is loading. Please wait.
Published byVincent Walters Modified over 9 years ago
1
Hey, Remember Java? Part 2 Written by J.J. Shepherd
3
File I/O Reading from a file works much like reading from the keyboard using a Scanner Concept Must be in a try-catch block Must close the stream at the end Scanner inputStream = new Scanner( new File(“./turtles.txt”)); int turtleAmt = inputStream.nextInt(); inputStream.close();
4
File I/O Writing to a file works much like System.out Concept for setting up Must be in a try-catch block Must close the file at the end PrintWriter outputStream = new PrintWriter( new FileOutputstream(fileName, true)); outputStream.println(“Hello World”); outputStream.close();
5
String Manipulation Used heavily in File I/O and throughout this course This is used to analyze and potentially modify strings
6
String Manipulation Use the methods in the following slides to assist The only one that is missing is.contains which will return a true or false value depending if the string contains that string anywhere More information on strings can be found in the javadoc https://docs.oracle.com/javase/7/docs/api/java/ lang/String.html
9
String Manipulation When in doubt… Read it character by character using charAt If you truly do not understand regular expressions (REGEX’s) then avoid using methods that use them
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.