Lec8 IO JUnit - Todays Announcements EE422C Data Structures...

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

View Full Document Right Arrow Icon
1 EE422C Data Structures Sarfraz Khurshid Lecture 8 Sep 21, 2010 Today’s Announcements Exam 1 on Sep 30, 12:30pm, in class Today I/O JUni JUnit Importing Library Classes Into Your Program Related classes are packaged together in the library java.lang is automatically imported Classes here include: String, Math, Object, Package, etc. Syntax import packageName . className ; Examples import java.util.Random; import java.awt.Rectangle; import java.io.* // all of them JAVA Class Packages Package Name Description java.lang Contains core JAVA classes, such as numeric classes, strings, etc. Is implicitly imported into every JAVA program java.awt Classes for graphics java.applet Classes for supporting applets java.io Classes for input and output of streams and files java.util Many utility classes,such as date java.net Classes for supporting network communications java.awt.image Classes for managing bitmap images java.awt.peer Platform specific GUI implementation classes others e.g. java.sql, java.rml Command Line Arguments public class YourProgramName { public static void main (String[ ] args) { . . . When your program is run > java YourProgramName argument0 argument1 The list that follows your program name is passed as an array of string arguments to your main method You can use them in your program just like parameters For example, the name of an input file to be used Files A file is — 1. A named collection of related data stored on a secondary storage device, such as disk, tape, or CD. • Permanent — data survives as long as media life. 2. A software object to model the transfer of data between the secondary storage device and main memory. Files on here: e.g. •BankAccount.java •assn2data.txt •myresume.doc •mypgm.exe Floppy disk
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Streams A stream (object) is an abstraction of the continuous one-way flow of data between a program and an external device (e.g., keyboard or screen) or secondary storage device (e.g. disk). The stream classes can be categorized into two types: byte streams and character streams. They transfer one data element at a time (a byte or character). Program In m emor y Output Stream File on disk Input S tream Simplified Reading of Input System.in has minimal set of features–it can only read one character at a time In Java 5.0, the java.util.Scanner class was added to read keyboard input in a convenient manner Scanner in = new Scanner(System. in ); Scanner methods include (among others): nextInt( ) reads an integer nextDouble( ) reads a double nextLine( ) reads a line (until a line separator is found) next( ) reads a token (until any delimiter is found) System. out .print( "Enter quantity: " ); int quantity = in.nextInt(); Byte Stream Classes InputStream SequenceInputStream PipedInputStream PushBackInputStream Buf eredInputStream LineNumberInputStream DataInputStream ObjectInputStream FilterInputStream FileInputStream ByteArrayInputStream OutputStream RandomAccessFile Ob ect PipedOutputStream StringBufferInputStream ByteArrayOutputStream ObjectOutputStream FilterOutputStream
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/02/2010 for the course EE 322C taught by Professor Nettles during the Spring '08 term at University of Texas at Austin.

Page1 / 6

Lec8 IO JUnit - Todays Announcements EE422C Data Structures...

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