Please send general questions to the google group

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: it then secure copy (scp) to ada CPSC 324 ‐‐ Spring 2010 4 2 1/28/10 Clarifications/Suggestions •  Learn to read and understand compile errors! •  Please send general questions to the google group –  [email protected] –  For questions whose answers you think will benefit the whole class –  Please don’t send your source code / answers though! •  I am not going to be able to tell you all the details … –  So, you’ll need to read the textbook :-) –  And also use the Java API (java’s javadocs) –  Knowing the basics plus how to navigate, read, and write code based on the Java API –  … will help make you a proficient java programmer! CPSC 324 ‐‐ Spring 2010 5 Scanner example import java.uIl.Scanner; import; public class ScannerTest { public staIc void main(String args) { We have a problem! File aFile = new File(“file.txt ”); Scanner in = new Scanner(aFile); while(in.hasNextLine()) System.out.println(in.nextLine()); [sbowers]$ javac in.close(); unreported excep,on }; must be caught or declared } to be thrown Scanner in = new Scanner(new File("lines.txt")); ^ 1 error CPSC 324 ‐‐ Spring 2010 6 3 1/28/10 Throwing Exceptions •  Methods (even constructors) can “throw exceptions” public Scanner(File source) throws FileNotFoundExcepIon { … do stuff if(source is not a valid ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online