2008 - err = new Printwriter(/dev//tty) } PrintWriter...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
INPUT/OUTPUT All input/output are in strings when doing input you are reading a strean of characters and with output you are writing a strean if characters every program is 3 streams standard input- system.in (redirectable) standard output- system.out (redirectable) standard error- system.err java foo < test.dat (input) java foo > test.out (output) File class constructor: File (s) File f = new File(“test.dat”) accessors exists () > Boolean canRead () > Boolean canWrite () > Boolean lastModified () > lang Mutator- delete () > void Printwriter class construstor printwriter(s) mutators print (object x) > void println(objectx)>void println()>void
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
close () > void public print (object x) { [[use this printwriter to print the string x. to string()]] public class System { public static Printwriter ost, err; public System () {//constructor out= new Pritnwriter(“/dev//tty”)
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: err = new Printwriter(/dev//tty) } PrintWriter myOut; myOut = new PrintWriter (test.out); my Out.println (Hello World); myOut.println(3 + 5); Scanner Class constructor- Scanner (f) Scanner input = new Scanner(Systen.in) input=newScanner(newFile(yes to do)) Accesors hasNext ()&gt;Boolean nextInt () &gt; int nextDouble () &gt; double nextLine () &gt; string Mutators close () &gt; void English-n &lt; first item (int) in the file do the following n times: read x, the next data item do something Java-int n = input.nextInt(); for (int I = 0; i&lt;n; i++) { double x = input.nextDouble(); doSomething (x); } English-as long as there is data in the file: read x, the next data item (double) do something w/x Java-[scanner input0 while (input.hasNext()) { double x = input.nextDouble (); doSomething (x); }...
View Full Document

Page1 / 3

2008 - err = new Printwriter(/dev//tty) } PrintWriter...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online