Java Review - Execution, IO and New Features

Java Review - Execution, IO and New Features -...

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

View Full Document Right Arrow Icon
Object-Oriented Design Java Review – Execution, I/O and New Features George Blankenship 1 CSCI 253 Java Review – Exec, I/O, New Features George Blankenship 1 Object Oriented Design: Java Review – Execution, I/O and New Features George Blankenship Java Topics • Running Java programs • Stream I/O Java Review – Exec, I/O, New Features George Blankenship 2 •N ew features Running Java Programs • Java Virtual Machine (JVM) – Program running on computer – Simulates a virtual computer running Java • JVM loads classes dynamically Upon first reference to class in program Java Review – Exec, I/O, New Features George Blankenship 3 – Upon first reference to class in program – Looks at directory / jar files in CLASSPATH • Invocation – java [-options] class [args. ..] – java [-options] -jar jarfile [args. ..] – -classpath • Search for required .class files • List of directories, JAR archives and ZIP archives – -version – Java version
Background image of page 1

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

View Full DocumentRight Arrow Icon
Object-Oriented Design Java Review – Execution, I/O and New Features George Blankenship 2 Jar Files • Zip file containing one or more .class files • Useful for bundling many Java files Java Review – Exec, I/O, New Features George Blankenship 4 • Treated by JVM as an entire directory • Create using – jar cf [filename] [files / directories to put in jar] – jar cvf Application.jar Application/* – Options – c (create), v (verbose), f (specify file) Java Topics • Running Java programs • Stream I/O Java Review – Exec, I/O, New Features George Blankenship 5 •N ew features Stream Input/Output • A connection carrying a sequence of data –By t e s InputStream, OutputStream – Characters FileReader, PrintWriter Java Review – Exec, I/O, New Features George Blankenship 6 • From a source to a destination – Keyboard – File –Ne two rk –M emo ry
Background image of page 2
Object-Oriented Design Java Review – Execution, I/O and New Features George Blankenship 3 Using Streams • Opening a stream – Connects program to external data – Location of stream specified at opening Java Review – Exec, I/O, New Features George Blankenship 7 •Ex am p l e – import java.io.* ; – Encapsulate in try/catch for exceptions – Open stream connection – Use stream read and / or write – Close stream Reading a File FileReader – Stream used to connect to a file Java Review – Exec, I/O, New Features George Blankenship 8 FileReader myFile new FileReader(fileName); – fileName (external) file of parent OS All references to fileName use myFile myFile.read() – read the file Standard Input/Output • Provided in System class in java.lang • System.in
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

Java Review - Execution, IO and New Features -...

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

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