STREAM WRITER , STREAM
READER, FILE WRITER, FILE
READER
ITECC03
COMPUTER PROGRAMMING 2
BRYAN CHRISTIAN M. BRIONES, MIT
CREATING TEXT FILES IN JAVA
• The following are the packages that we need to import
• Import [Link].*
• Or more specific
• Import [Link]
• Import [Link]
CREATING A FILE
• We will use a function called file that in the [Link] import
• Try {
• File file = new file(“[Link]”);
• If (![Link]()){
• [Link]();
•}
• Catch(IOException e){
• [Link]();
•}
WRITING INSIDE THE FILE
•PrintWriter pw = new PrintWriter(file);
•[Link](“this my file content”)
•[Link](10000);
•[Link]
MACHINE PROBLEM
• Create a java program with GUI wherein the program will accept an input of
a filename and the content of the file.
• It will create a file and write in
it its content once write is pressed
READING A FILE
• The following are the packages that we will need to
import
• [Link];
• [Link];
• [Link]
• BufferedReader br = null;
READING A FILE
• Try{
• Br = new bufferedReader(new FileReader(“[Link]”));
• String line;
• While( l(line = [Link]()) != null){
• [Link](line);
•}
• Catch (IOException){
•}
• Finally (
• [Link]();
•}
MACHINE PROBLEM
• Create a JAVA GUI wherein it will read a file when the read button is pressed