{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Exam 2 Notes - br.close pw.close FileInputStream and...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Checked exceptions are exceptions that are not runtime exceptions and are checked by the compiler; the compiler checks that these exceptions are caught or specified as thrown. FileReader and FileWriter: socialIn = new File("social.txt"); socOut1 = new File("socOut1.txt"); fr = new FileReader(socialIn); fw = new FileWriter(socOut1); int r; while ((r = fr.read()) != -1) { fw.write(r);} fr.close(); fw.close(); BufferedReader and PrintWriter: socialIn = new File("social.txt"); socOut2 = new File("socOut2.txt"); fr = new FileReader(socialIn); fw = new FileWriter(socOut2); br = new BufferedReader(fr); pw = new PrintWriter(fw,true); //autoflush on println() String inLine; while ((inLine = br.readLine()) != null) {pw.println(inLine);}
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: br.close(); pw.close(); FileInputStream and FileOutputStream: socialIn = new File("social.txt"); socialOut = new File("socialOut.txt"); fis = new FileInputStream(socialIn); fos = new FileOutputStream(socialOut); int r; while ((r = fis.read()) != -1) {fos.write(r);} fis.close(); fos.close(); ObjectInputStream and ObjectOutputStream: inventoryFile = new File("CandyBarInventory.dat"); fis = new FileInputStream(inventoryFile); ois = new ObjectInputStream(fis); inventory = (Vector<CandyBar>)ois.readObject(); ois.close(); fos = new FileOutputStream(inventoryFile); oos = new ObjectOutputStream(fos); oos.writeObject(inventory); oos.close();...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online