Java IO and C++ Streams
|
|
- Elwin Sharp
- 6 years ago
- Views:
Transcription
1 Java IO and C++ Streams October 22, 2004 Operator Overloading in C p. 1/31
2 Outline Java IO InputStream/OutputStream FilterInputStream/FilterOutputStream DataInputStream/DataOutputStream Reader/Writer Encodings C++ Streams Operator Overloading in C p. 2/31
3 java.io - Intro Two main abstractions: streams of bytes InputStream abstract class is the superclass of all classes representing an input stream of bytes OutputStream abstract class is the superclass of all classes representing an output stream of bytes streams of characters Operator Overloading in C p. 3/31
4 java.io - Intro Two main abstractions: streams of bytes streams of characters Reader abstract class is the superclass of all classes representing an input stream of characters Writer abstract class is the superclass of all classes representing an output stream of characters Operator Overloading in C p. 4/31
5 OutputStream must always provide at least a method that writes one byte of output methods: void close() void flush() void write(byte[] b) void write(byte[] b, int off, int len) abstract void write(int b) subclasses Operator Overloading in C p. 5/31
6 OutputStream (cont) subclasses: ByteArrayOutputStream data is written into a byte array the buffer automatically grows as data is written to it FileOutputStream writing data to a File or to a FileDescriptor meant for writing streams of raw byte FilterOutputStream ObjectOutputStream PipedOutputStream Operator Overloading in C p. 6/31
7 OutputStream (cont) subclasses: ByteArrayOutputStream FileOutputStream FilterOutputStream superclass of all classes that filter output streams subclasses: BufferedOutputStream, CheckedOutputStream, CipherOutputStream, DataOutputStream, DeflaterOutputStream, DigestOutputStream, PrintStream ObjectOutputStream PipedOutputStream Operator Overloading in C p. 7/31
8 OutputStream (cont) subclasses: ByteArrayOutputStream FileOutputStream FilterOutputStream ObjectOutputStream writes primitive data types and graphs of Java objects only objects that support the java.io.serializable interface can be written to streams primitive data types can also be written PipedOutputStream can be connected to a piped input stream to create a communications pipe Operator Overloading in C p. 8/31
9 FilterOutputStream writes data to another OutputStream two kind of subclasses: processing of the data: BufferedOutputStream CheckedOutputStream CipherOutputStream DeflaterOutputStream GZIPOutputStream ZipOutputStream DigestOutputStream provides an expanded interface: DataOutputStream PrintStream: polymorphic print and println, printf Operator Overloading in C p. 9/31
10 DataOutputStream Extended interface provided by DataOutputStream: void writeboolean(boolean v) void writebyte(int v) void writebytes(string s) void writechar(int v) void writechars(string s) void writedouble(double v) void writefloat(float v) void writeint(int v) void writelong(long v) void writeshort(int v) void writeutf(string str) Operator Overloading in C p. 10/31
11 OutputStream - Example FileOutputStream fileout = new FileOutputStream("myfile"); // add buffering BufferedOutputStream bufout = new BufferedOutputStream(fileOut); // add compression GZIPOutputStream gzout = new GZIPOutputStream(bufOut); // interface for binary data DataOutputStream out = new DataOutputStream(gzOut); // some writing out.writeint(n); out.writedouble(d); Operator Overloading in C p. 11/31
12 OutputStream - What if? FileOutputStream fileout = new FileOutputStream("myfile"); BufferedOutputStream bufout = new BufferedOutputStream(fileOut); GZIPOutputStream gzout = new GZIPOutputStream(bufOut); DataOutputStream out1 = new DataOutputStream(gzOut); DataOutputStream out2 = new DataOutputStream(bufOut); out1.writeint(n); out2.writedouble(d); Operator Overloading in C p. 12/31
13 OutputStream - What if? FileOutputStream fileout = new FileOutputStream("myfile"); BufferedOutputStream bufout = new BufferedOutputStream(fileOut); GZIPOutputStream gzout = new GZIPOutputStream(bufOut); DataOutputStream out1 = new DataOutputStream(gzOut); DataOutputStream out2 = new DataOutputStream(bufOut); out1.writeint(n); out2.writedouble(d); The output will be corrupted! Operator Overloading in C p. 13/31
14 OutputStream - A common construction DataOutputStream out = new DataOutputStream( new GZIPOutputStream( new BufferedOutputStream( FileOutputStream("myfile")))); out.writeint(n); out.writedouble(d); Operator Overloading in C p. 14/31
15 InputStream similar with OutputStream but in reverse subclasses: ByteArrayInputStream FileInputStream FilterInputStream ObjectInputStream PipedInputStream SequenceInputStream represents the logical concatenation of other input streams Operator Overloading in C p. 15/31
16 The other world: characters Writer methods that a subclass must implement are: write(char[], int, int), flush(), and close() subclasses: BufferedWriter, CharArrayWriter, FilterWriter, OutputStreamWriter, FileWriter, PipedWriter, PrintWriter, StringWriter Reader methods that a subclass must implement are read(char[], int, int) and close() subclasses: BufferedReader, CharArrayReader, FilterReader, InputStreamReader, PipedReader, StringReader What is the big difference? Operator Overloading in C p. 16/31
17 The other world: characters Writer methods that a subclass must implement are: write(char[], int, int), flush(), and close() subclasses: BufferedWriter, CharArrayWriter, FilterWriter, OutputStreamWriter, FileWriter, PipedWriter, PrintWriter, StringWriter Reader methods that a subclass must implement are read(char[], int, int) and close() subclasses: BufferedReader, CharArrayReader, FilterReader, InputStreamReader, PipedReader, StringReader What is the big difference? Encodings! Operator Overloading in C p. 17/31
18 InputStreamReader/OutputStreamWriter InputStreamReader is a bridge from byte streams to character streams reads bytes and decodes them into characters using a specified charset OutputStreamWriter the opposite of InputStreamReader Operator Overloading in C p. 18/31
19 Encodings JDKTM 5.0 Documentation Tool Docs Internationalization Tools native2ascii Supported Encodings docs/guide/intl/encoding.doc.html Operator Overloading in C p. 19/31
20 Another Universe: C++ Streams Operator Overloading in C p. 20/31
21 Reference The C++ Programming Language, Third Edition by Bjarne Stroustrup. Published by Addison Wesley Longman, Inc. Operator Overloading in C p. 21/31
22 Standard Streams Several standard streams are declared in <iostream>: ostream cout // standard output stream // of char ostream cerr // standard unbuffered output // stream for error messages ostream clog // standard output stream for // error messages wostream wcout; // wide stream ver. of cout wostream wcerr; // wide stream ver. of cerr wostream wclog; // wide stream ver. of clog Operator Overloading in C p. 22/31
23 istream Provides:» get getline read gcount putback tie Operator Overloading in C p. 23/31
24 ostream Provides: «put write Operator Overloading in C p. 24/31
25 State bool good() const; // next op. might succeed bool eof() const; // end of input seen bool fail() const; // next op. will fail bool bad() const; // stream is corrupted iostate rdstate() const; // get io state flags void clear(iostate f = goodbit); // set io state flags void setstate(iostate f) { clear(rdstate() f); // add f to iostate flags } operator void*() const; // nonzero if!fail() bool operator!() const { return fail(); } Operator Overloading in C p. 25/31
26 Formating static const fmtflags skipws, // skip whitespace on input left // pad after value right, // pad before value internal, // pad between sign and value boolalpha, // use symbolic representation dec, // base 10 output (decimal) hex, // base 16 output (hexadecimal) oct, // base 8 output (octal) scientific, // d.ddddddedd fixed, // dddd.dd showbase, // prefix oct by 0 and hex by 0x showpoint, // print trailing zeros showpos, // explicit + for positive ints uppercase; // E, X rather than e, x Operator Overloading in C p. 26/31
27 Formating (cont) // read flags fmtflags flags() const; // set flags fmtflags flags(fmtflags f); // add flags fmtflags setf(fmtflags f) { return flags(flags() f); } // clear flags void unsetf(fmtflags mask) { flags(flags()& mask); } Operator Overloading in C p. 27/31
28 Manipulators declared in <iomanip>, namespase std Manipulators: boolalpha, noboolalpha showbase, noshowbase showpoint, noshowpoint showpos, noshowpos skipws, noskipws, ws uppercase, nouppercase internal left, right dec, hex, oct fixed, scientific Operator Overloading in C p. 28/31
29 Manipulators (cont) Manipulators (cont): endl, ends flush resetioflags, setioflags setbase setfill setprecision setw Operator Overloading in C p. 29/31
30 Other kinds of streams File Streams <fstream> ifstream, ofstream, fstream String Streams <sstream> istringstream, ostringstream, stringstream wistringstream, wostringstream, wstringstream Stream Buffers Operator Overloading in C p. 30/31
31 That s all! Have a nice weekend! Operator Overloading in C p. 31/31
Streams - Object input and output in C++
Streams - Object input and output in C++ Dr. Donald Davendra Ph.D. Department of Computing Science, FEI VSB-TU Ostrava Dr. Donald Davendra Ph.D. (Department of Computing Streams - Object Science, input
More informationJOSE LUIS JUAREZ VIVEROS com) has a. non-transferable license to use this Student Guide
Module 10 I/O Fundamentals Objectives Upon completion of this module, you should be able to: Write a program that uses command-line arguments and system properties Examine the Properties class Construct
More informationSoftware 1 with Java. Recitation No. 9 (Java IO) December 10,
Software 1 with Java Recitation No. 9 (Java IO) December 10, 2006 1 The java.io package The java.io package provides: Classes for reading input Classes for writing output Classes for manipulating files
More information7 Streams and files. Overview. Binary data vs text. Binary data vs text. Readers, writers, byte streams. input-output
Overview 7 Streams and files import java.io.*; Binary data vs textual data Simple file processing - examples The stream model Bytes and characters Buffering Byte streams Character streams Binary streams
More informationSoftware 1 with Java. Recitation No. 7 (Java IO) May 29,
Software 1 with Java Recitation No. 7 (Java IO) May 29, 2007 1 The java.io package The java.io package provides: Classes for reading input Classes for writing output Classes for manipulating files Classes
More informationSoftware 1. Java I/O
Software 1 Java I/O 1 The java.io package The java.io package provides: Classes for reading input Classes for writing output Classes for manipulating files Classes for serializing objects 2 Streams A stream
More informationThe Java I/O System. Binary I/O streams (ASCII, 8 bits) The decorator design pattern Character I/O streams (Unicode, 16 bits)
The Java I/O System Binary I/O streams (ASCII, 8 bits) InputStream OutputStream The decorator design pattern Character I/O streams (Unicode, 16 bits) Reader Writer Comparing binary I/O to character I/O
More informationModule 11 The C++ I/O System
Table of Contents Module 11 The C++ I/O System CRITICAL SKILL 11.1: Understand I/O streams... 2 CRITICAL SKILL 11.2: Know the I/O class hierarchy... 3 CRITICAL SKILL 11.3: Overload the > operators...
More informationChapter 4 Java I/O. X i a n g Z h a n g j a v a c o s q q. c o m
Chapter 4 Java I/O X i a n g Z h a n g j a v a c o s e @ q q. c o m Content 2 Java I/O Introduction File and Directory Byte-stream and Character-stream Bridge between b-s and c-s Random Access File Standard
More informationJava How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved.
Java How to Program, 9/e Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. Data stored in variables and arrays is temporary It s lost when a local variable goes out of scope or when
More informationChapter 12 - C++ Stream Input/Output
Chapter 12 - C++ Stream Input/Output 1 12.1 Introduction 12.2 Streams 12.2.1 Classic Streams vs. Standard Streams 12.2.2 iostream Library Header Files 12.2.3 Stream Input/Output Classes and Objects 12.3
More informationCSD Univ. of Crete Fall Files, Streams, Filters
Files, Streams, Filters 1 CSD Univ. of Crete Fall 2008 Introduction Files are often thought of as permanent data storage (e.g. floppy diskettes) When a file is stored on a floppy or hard disk, the file's
More informationExceptions and Working with Files
Exceptions and Working with Files Creating your own Exceptions. You have a Party class that creates parties. It contains two fields, the name of the host and the number of guests. But you don t want to
More informationThe I/O Package. THE Java platform includes a number of packages that are concerned with the CHAPTER20
CHAPTER20 The I/O Package From a programmer s point of view, the user is a peripheral that types when you issue a read request. Peter Williams THE Java platform includes a number of packages that are concerned
More informationbasic_fstream<chart, traits> / \ basic_ifstream<chart, traits> basic_ofstream<chart, traits>
The C++ I/O System I/O Class Hierarchy (simplified) ios_base ios / \ istream ostream \ / iostream ifstream fstream ofstream The class ios_base -- public variables and methods The derived classes istream,
More informationPiyush Kumar. input data. both cout and cin are data objects and are defined as classes ( type istream ) class
C++ IO C++ IO All I/O is in essence, done one character at a time For : COP 3330. Object oriented Programming (Using C++) http://www.compgeom.com/~piyush/teach/3330 Concept: I/O operations act on streams
More informationJava Input / Output. CSE 413, Autumn 2002 Programming Languages.
Java Input / Output CSE 413, Autumn 2002 Programming Languages http://www.cs.washington.edu/education/courses/413/02au/ 18-November-2002 cse413-18-javaio 2002 University of Washington 1 Reading Readings
More informationCSC 1214: Object-Oriented Programming
CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: www: materials: e-learning environment: office: alt. office: jkizito@cis.mak.ac.ug http://serval.ug/~jona http://serval.ug/~jona/materials/csc1214
More informationCSB541 Network Programming 網路程式設計. Ch.2 Streams 吳俊興國立高雄大學資訊工程學系
CSB541 Network Programming 網路程式設計 Ch.2 Streams 吳俊興國立高雄大學資訊工程學系 Outline 2.1 Output Streams 2.2 Input Streams 2.3 Filter Streams 2.4 Readers and Writers 2 Java I/O Built on streams I/O in Java is organized
More informationStreams. Programação Orientada por Objetos (POO) Centro de Cálculo Instituto Superior de Engenharia de Lisboa
Streams Programação Orientada por Objetos (POO) Centro de Cálculo Instituto Superior de Engenharia de Lisboa Pedro Alexandre Pereira (palex@cc.isel.ipl.pt) 4 hieraquias de streams em Java Escrita Leitura
More informationWriting usable APIs in practice
Writing usable APIs in practice SyncConf 2013 Giovanni Asproni gasproni@asprotunity.com @gasproni Summary API definition Two assumptions Why bother with usability Some usability concepts Some techniques
More informationSoftware 1. תרגול 9 Java I/O
Software 1 תרגול 9 Java I/O 1 The java.io package The java.io package provides: Classes for reading input Classes for writing output Classes for manipulating files Classes for serializing objects 2 Streams
More informationCS11 Advanced C++ Lecture 2 Fall
CS11 Advanced C++ Lecture 2 Fall 2006-2007 Today s Topics C++ strings Access Searching Manipulation Converting back to C-style strings C++ streams Error handling Reading unformatted character data Simple
More informationSoftware 1 with Java. The java.io package. Streams. Streams. Streams. InputStreams
The java.io package Software with Java Java I/O Mati Shomrat and Rubi Boim The java.io package provides: Classes for reading input Classes for writing output Classes for manipulating files Classes for
More informationSystem.out.format("The square root of %d is %f.%n", i, r);
1 Input/Output in Java Vedi anche: http://java.sun.com/docs/books/tutorial/essential/io/index.html 2 Formattazione public class Root2 { public static void main(string[] args) { int i = 2; double r = Math.sqrt(i);
More information09-1. CSE 143 Java GREAT IDEAS IN COMPUTER SCIENCE. Overview. Data Representation. Representation of Primitive Java Types. Input and Output.
CSE 143 Java Streams Reading: 19.1, Appendix A.2 GREAT IDEAS IN COMPUTER SCIENCE REPRESENTATION VS. RENDERING 4/28/2002 (c) University of Washington 09-1 4/28/2002 (c) University of Washington 09-2 Topics
More informationתוכנה 1 תרגול 8 קלט/פלט רובי בוים ומתי שמרת
תוכנה 1 תרגול 8 קלט/פלט רובי בוים ומתי שמרת A Typical Program Most applications need to process some input and produce some output based on that input The Java IO package (java.io) is to make that possible
More informationInput, Output and Exceptions. COMS W1007 Introduction to Computer Science. Christopher Conway 24 June 2003
Input, Output and Exceptions COMS W1007 Introduction to Computer Science Christopher Conway 24 June 2003 Input vs. Output We define input and output from the perspective of the programmer. Input is data
More informationCS 251 Intermediate Programming Java I/O Streams
CS 251 Intermediate Programming Java I/O Streams Brooke Chenoweth University of New Mexico Spring 2018 Basic Input/Output I/O Streams mostly in java.io package File I/O mostly in java.nio.file package
More informationPrinceton University COS 333: Advanced Programming Techniques A Subset of Java
Princeton University COS 333: Advanced Programming Techniques A Subset of Java Program Structure public class Hello public static void main(string[] args) // Print "hello, world" to stdout. System.out.println("hello,
More informationSpecial error return Constructors do not have a return value What if method uses the full range of the return type?
23 Error Handling Exit program (System.exit()) usually a bad idea Output an error message does not help to recover from the error Special error return Constructors do not have a return value What if method
More informationI/O in Java I/O streams vs. Reader/Writer. HW#3 due today Reading Assignment: Java tutorial on Basic I/O
I/O 10-7-2013 I/O in Java I/O streams vs. Reader/Writer HW#3 due today Reading Assignment: Java tutorial on Basic I/O public class Swimmer implements Cloneable { public Date geteventdate() { return (Date)
More informationFig: iostream class hierarchy
Unit 6: C++ IO Systems ================== Streams: Θ A stream is a logical device that either produces or consumes information. Θ A stream is linked to a physical device by the I/O system. Θ All streams
More informationPIC 20A Streams and I/O
PIC 20A Streams and I/O Ernest Ryu UCLA Mathematics Last edited: December 7, 2017 Why streams? Often, you want to do I/O without paying attention to where you are reading from or writing to. You can read
More information10.1 Overview 162 CHAPTER 10 CHARACTER STREAMS
C H A P T E R 1 0 Character streams 10.1 Overview 162 10.2 Character encoding 164 10.3 Class Writer 167 10.4 Class Reader 169 10.5 Class OutputStreamWriter 171 10.6 Class InputStreamReader 173 10.7 An
More informationI/O Streams and Standard I/O Devices (cont d.)
Chapter 3: Input/Output Objectives In this chapter, you will: Learn what a stream is and examine input and output streams Explore how to read data from the standard input device Learn how to use predefined
More informationSoftware 1. The java.io package. Streams. Streams. Streams. InputStreams
The java.io package Software 1 תרגול 9 Java I/O The java.io package provides: Classes for reading input Classes for writing output Classes for manipulating files Classes for serializing objects 1 2 Streams
More informationCOMP 213. Advanced Object-oriented Programming. Lecture 19. Input/Output
COMP 213 Advanced Object-oriented Programming Lecture 19 Input/Output Input and Output A program that read no input and produced no output would be a very uninteresting and useless thing. Forms of input/output
More informationChapter 17 Binary I/O. Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
Chapter 17 Binary I/O 1 Motivations Data stored in a text file is represented in human-readable form. Data stored in a binary file is represented in binary form. You cannot read binary files. They are
More informationDarshan Institute of Engineering & Technology for Diploma Studies
Streams A stream is a sequence of data. In Java a stream is composed of bytes. In java, 3 streams are created for us automatically. 1. System.out : standard output stream 2. System.in : standard input
More informationBasic I/O - Stream. Java.io (stream based IO) Java.nio(Buffer and channel-based IO)
I/O and Scannar Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 I/O operations Three steps:
More informationChapter 21 - C++ Stream Input/Output
Chapter 21 - C++ Stream Input/Output Outline 21.1 Introduction 21.2 Streams 21.2.1 Iostream Library Header Files 21.2.2 Stream Input/Output Classes and Objects 21.3 Stream Output 21.3.1 Stream-Insertion
More informationDecorator Pattern. Decorator Pattern. Decorator Problems Decorator Examples Proxy Pattern. Motivation Structure Decorator vs Inheritance vs Strategy
Decorator Pattern Decorator Pattern Motivation Structure Decorator vs Inheritance vs Strategy Decorator Problems Decorator Examples Proxy Pattern 1 Vibrating & Skin Phones 2 Implementation with Inheritance
More informationCPS122 Lecture: Input-Output
CPS122 Lecture: Input-Output Objectives: Last Revised April 3, 2017 1. To discuss IO to System.in/out/err 2. To introduce the abstract notion of a stream 3. To introduce the java File, Input/OutputStream,
More informationJan 27, C++ STL Streams. Daniel Maleike
C++ STL Streams Why Stream-IO? The STL way for I/O Input, output, formatting, file access More type-safe than printf(), scanf() Extensible with user defined types (classes) Inheritable, i.e. custom I/O
More informationInput and Output. Data Processing Course, I. Hrivnacova, IPN Orsay
Input and Output Data Processing Course, I. Hrivnacova, IPN Orsay Output to the Screen Input from the Keyboard IO Headers Output to a File Input from a File Formatting I. Hrivnacova @ Data Processing Course
More informationI/O Streams. Object-oriented programming
I/O Streams Object-oriented programming Outline Concepts of Data Streams Streams and Files File class Text file Binary file (primitive data, object) Readings: GT, Ch. 12 I/O Streams 2 Data streams Ultimately,
More informationCS112 Lecture: Streams
CS112 Lecture: Streams Objectives: Last Revised March 30, 2006 1. To introduce the abstract notion of a stream 2. To introduce the java File, Input/OutputStream, and Reader/Writer abstractions 3. To show
More informationInput/Output Streams: Customizing
DM560 Introduction to Programming in C++ Input/Output Streams: Customizing Marco Chiarandini Department of Mathematics & Computer Science University of Southern Denmark [Based on slides by Bjarne Stroustrup]
More informationOverview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE
CSE 143 Overview Topics Data representation bits and bytes Streams communicating with the outside world Basic Java files Other stream classes Streams Reading: Ch. 16 10/20/2004 (c) 2001-4, University of
More informationSoftware Practice 1 - File I/O
Software Practice 1 - File I/O Stream I/O Buffered I/O File I/O with exceptions CSV format Practice#6 Prof. Joonwon Lee T.A. Jaehyun Song Jongseok Kim (42) T.A. Sujin Oh Junseong Lee 1 (43) / 38 2 / 38
More informationPieter van den Hombergh Richard van den Ham. March 13, 2018
Pieter van den Hombergh Richard van den Ham Fontys Hogeschool voor Techniek en Logistiek March 13, 2018 /FHTenL March 13, 2018 1/23 Topics /FHTenL March 13, 2018 2/23 Figure: Taken from the Oracle/Sun
More informationOverview CSE 143. Input and Output. Streams. Other Possible Kinds of Stream Converters. Stream after Stream... CSE143 Wi
CSE 143 Overview Topics Streams communicating with the outside world Basic Java files Other stream classes Streams Reading: Ch. 16 2/3/2005 (c) 2001-5, University of Washington 12-1 2/3/2005 (c) 2001-5,
More informationObjec&ves STANDARD ERROR. Standard Error Streams. Ø Byte Streams Ø Text Streams 10/5/16. Oct 5, 2016 Sprenkle - CSCI209 1
Objec&ves Standard Error Streams Ø Byte Streams Ø Text Streams Oct 5, 2016 Sprenkle - CSCI209 1 STANDARD ERROR Oct 5, 2016 Sprenkle - CSCI209 2 1 Standard Streams Preconnected streams Ø Standard Out: stdout
More informationCS2141 Software Development using C/C++ Stream I/O
CS2141 Software Development using C/C++ Stream I/O iostream Two libraries can be used for input and output: stdio and iostream The iostream library is newer and better: It is object oriented It can make
More informationSoftware Development & Education Center. Java Platform, Standard Edition 7 (JSE 7)
Software Development & Education Center Java Platform, Standard Edition 7 (JSE 7) Detailed Curriculum Getting Started What Is the Java Technology? Primary Goals of the Java Technology The Java Virtual
More informationOverview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE. Representation of Primitive Java Types. CSE143 Au
Overview CSE 143 Topics Data representation bits and bytes Streams communicating with the outside world Basic Java files Other stream classes Streams Reading: Sec. 19.1, Appendix A2 11/2/2003 (c) 2001-3,
More informationOverview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE
Overview CSE 143 Topics Data representation bits and bytes Streams communicating with the outside world Basic Java files Other stream classes Streams Reading: Sec. 19.1, Appendix A2 11/2/2003 (c) 2001-3,
More informationOverview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE. Representation of Primitive Java Types. CSE143 Sp
Overview CSE 143 Topics Data representation bits and bytes Streams communicating with the outside world Basic Java files Other stream classes Streams Reading: Ch. 16 4/27/2004 (c) 2001-4, University of
More informationChapter 21 - C++ Stream Input/Output
Chapter 21 - C++ Stream Input/Output Outline 21.1 Introduction 21.2 Streams 21.2.1 Iostream Library Header Files 21.2.2 Stream Input/Output Classes and Objects 21.3 Stream Output 21.3.1 Stream-Insertion
More informationExample: Copying the contents of a file
Administrivia Assignment #4 is due imminently Due Thursday April 8, 10:00pm no late assignments will be accepted Sign up in the front office for a demo time Dining Philosophers code is online www.cs.ubc.ca/~norm/211/2009w2/index.html
More informationPrinciples of Software Construction: Objects, Design and Concurrency. Design Case Study: Stream I/O. toad
Principles of Software Construction: Objects, Design and Concurrency Design Case Study: Stream I/O 15-214 toad Christian Kästner Charlie Garrod School of Computer Science 2014 C Kästner, C Garrod, J Aldrich,
More informationCS201 Solved MCQs.
15.1 Answer each of the following: a. Input/output in C++ occurs as of bytes. b. The stream manipulators that format justification are, and. c. Member function can be used to set and reset format state.
More informationChapter 10. IO Streams
Chapter 10 IO Streams Java I/O The Basics Java I/O is based around the concept of a stream Ordered sequence of information (bytes) coming from a source, or going to a sink Simplest stream reads/writes
More informationWriting usable APIs in practice
Writing usable APIs in practice NDC Oslo 2013 email: gasproni@asprotunity.com twitter: @gasproni linkedin: http://www.linkedin.com/in/gasproni Asprotunity Ltd API Any well-defined interface that defines
More informationCPS122 Lecture: Input-Output
CPS122 Lecture: Input-Output Objectives: Last Revised January 19, 2010 1. To discuss IO to System.in/out/err 2. To introduce the abstract notion of a stream 3. To introduce the java File, Input/OutputStream,
More informationby Pearson Education, Inc. All Rights Reserved. 2
The C++ standard libraries provide an extensive set of input/output capabilities. C++ uses type-safe I/O. Each I/O operation is executed in a manner sensitive to the data type. If an I/O member function
More informationStandard I/O in C and C++
Introduction to Computer and Program Design Lesson 7 Standard I/O in C and C++ James C.C. Cheng Department of Computer Science National Chiao Tung University Standard I/O in C There three I/O memory buffers
More informationObjec&ves. Review. Standard Error Streams
Objec&ves Standard Error Streams Ø Byte Streams Ø Text Streams Oct 5, 2016 Sprenkle - CSCI209 1 Review What are benefits of excep&ons What principle of Java do files break if we re not careful? What class
More informationITI Introduction to Computer Science II
ITI 1121. Introduction to Computer Science II Laboratory 8 Winter 2015 [ PDF ] Objectives Introduction to Java I/O (input/output) Further understanding of exceptions Introduction This laboratory has two
More information10/23/02 21:20:33 IO_Examples
1 Oct 22 22:07 2000 extractor1.c Page 1 istream &operator>>( istream &in, Point &p ){ char junk; in >> junk >> p.x >> junk >> p.y >> junk; return in; 2 Oct 22 22:07 2000 extractor2.c Page 1 istream &operator>>(
More informationC++ Input/Output: Streams
C++ Input/Output: Streams Basic I/O 1 The basic data type for I/O in C++ is the stream. C++ incorporates a complex hierarchy of stream types. The most basic stream types are the standard input/output streams:
More informationAdvanced I/O Concepts
Advanced Object Oriented Programming Advanced I/O Concepts Seokhee Jeon Department of Computer Engineering Kyung Hee University jeon@khu.ac.kr 1 1 Streams Diversity of input sources or output destinations
More informationStrings and Streams. Professor Hugh C. Lauer CS-2303, System Programming Concepts
Strings and Streams Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter
More informationFile IO. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 20
File IO Computer Science and Engineering College of Engineering The Ohio State University Lecture 20 I/O Package Overview Package java.io Core concept: streams Ordered sequences of data that have a source
More informationFile. Long term storage of large amounts of data Persistent data exists after termination of program Files stored on secondary storage devices
Java I/O File Long term storage of large amounts of data Persistent data exists after termination of program Files stored on secondary storage devices Magnetic disks Optical disks Magnetic tapes Sequential
More informationChapter 11 Customizing I/O
Chapter 11 Customizing I/O Hartmut Kaiser hkaiser@cct.lsu.edu http://www.cct.lsu.edu/~hkaiser/fall_2010/csc1253.html Slides adapted from: Bjarne Stroustrup, Programming Principles and Practice using C++
More informationChapter 11 Customizing I/O
Chapter 11 Customizing I/O Bjarne Stroustrup www.stroustrup.com/programming Overview Input and output Numeric output Integer Floating point File modes Binary I/O Positioning String streams Line-oriented
More information输 入输出相关类图. DataInput. DataOutput. java.lang.object. FileInputStream. FilterInputStream. FilterInputStream. FileOutputStream
输 入 / 输出 杨亮 流的分类 输 入输出相关类图 OutputStream FileOutputStream DataInputStream ObjectOutputStream FilterInputStream PipedOutputStream DataOutput InputStream DataInputStream PrintStream ObjectInputStream PipedInputStream
More informationJonathan Aldrich Charlie Garrod
Principles of So3ware Construc9on: Objects, Design, and Concurrency Part 3: Design Case Studies Design Case Study: Java I/O Jonathan Aldrich Charlie Garrod School of Computer Science 1 Administrivia Homework
More informationIntroduction to C++ (Extensions to C)
Introduction to C++ (Extensions to C) C is purely procedural, with no objects, classes or inheritance. C++ is a hybrid of C with OOP! The most significant extensions to C are: much stronger type checking.
More informationFiles and Streams
Files and Streams 4-18-2006 1 Opening Discussion Do you have any questions about the quiz? What did we talk about last class? Do you have any questions about the assignment? What are files and why are
More informationChapter 8: Files and Security
Java by Definition Chapter 8: Files and Security Page 1 of 90 Chapter 8: Files and Security All programs and applets we created up to this point had one feature in common: as soon as the program or applet
More informationUEE1303(1070) S 12 Object-Oriented Programming in C++
Computational Intelligence on Automation Lab @ NCTU Learning Objectives UEE1303(1070) S 12 Object-Oriented Programming in C++ Lecture 06: Streams and File Input/Output I/O stream istream and ostream member
More informationObject-Oriented Programming in the Java language
Object-Oriented Programming in the Java language Part 5. Exceptions. I/O in Java Yevhen Berkunskyi, NUoS eugeny.berkunsky@gmail.com http://www.berkut.mk.ua Exceptions Exceptions in Java are objects. All
More informationSetting Justification
Setting Justification Formatted I/O 1 Justification - Justification refers to the alignment of data within a horizontal field. - The default justification in output fields is to the right, with padding
More informationObject Oriented Programming Using C++ UNIT-3 I/O Streams
File - The information / data stored under a specific name on a storage device, is called a file. Stream - It refers to a sequence of bytes. Text file - It is a file that stores information in ASCII characters.
More informationBasic Java IO Decorator pattern Advanced Java IO. Java IO - part 2 BIU OOP. BIU OOP Java IO - part 2
Java IO - part 2 BIU OOP Table of contents 1 Basic Java IO What do we know so far? What s next? 2 Example Overview General structure 3 Stream Decorators Serialization What do we know so far? What s next?
More informationIntermediate Programming Methodologies in C++ CIS22B. Joe Bentley
Intermediate Programming Methodologies in C++ CIS22B Joe Bentley DeAnzaCollege Computer Information System September 2018 Table of Contents Review...3 CIS22A Basics...3 An Old CIS22A Midterm... 3 Warning
More informationWe will exclusively use streams for input and output of data. Intro Programming in C++
C++ Input/Output: Streams The basic data type for I/O in C++ is the stream. C++ incorporates a complex hierarchy of stream types. The most basic stream types are the standard input/output streams: 1 istream
More informationObjects and streams and files CS427: Elements of Software Engineering
Objects and streams and files CS427: Elements of Software Engineering Lecture 6.2 (C++) 10am, 13 Feb 2012 CS427 Objects and streams and files 1/18 Today s topics 1 Recall...... Dynamic Memory Allocation...
More informationObject Oriented Design with UML and Java. PART VIII: Java IO
Object Oriented Design with UML and Java PART VIII: Java IO Copyright David Leberknight and Ron LeMaster. Version 2011 java.io.* & java.net.* Java provides numerous classes for input/output: java.io.inputstream
More informationWhen working with files and directories, it is often
VERIFY THAT A FILE OR DIRECTORY EXISTS When working with files and directories, it is often necessary to verify that a file or directory exists before performing an action. For example, you should verify
More informationChapter 10 Input Output Streams
Chapter 10 Input Output Streams ICT Academy of Tamil Nadu ELCOT Complex, 2-7 Developed Plots, Industrial Estate, Perungudi, Chennai 600 096. Website : www.ictact.in, Email : contact@ictact.in, Phone :
More information1.00 Lecture 30. Sending information to a Java program
1.00 Lecture 30 Input/Output Introduction to Streams Reading for next time: Big Java 15.5-15.7 Sending information to a Java program So far: use a GUI limited to specific interaction with user sometimes
More informationWeek 3: File I/O and Formatting 3.7 Formatting Output
Week 3: File I/O and Formatting 3.7 Formatting Output Formatting: the way a value is printed: Gaddis: 3.7, 3.8, 5.11 CS 1428 Fall 2014 Jill Seaman spacing decimal points, fractional values, number of digits
More informationJAVA V Input/Output Java, winter semester
JAVA Input/Output 1 Overview package java.io basic input/output streams bytes since JDK1.1 Reader and Writer chars (Unicode) package java.nio since JDK1.4 channels, buffers increased performance classes
More informationJAVA Input/Output Java, winter semester
JAVA Input/Output 1 Overview package java.io basic input/output streams bytes since JDK1.1 Reader and Writer chars (Unicode) package java.nio since JDK1.4 channels, buffers increased performance classes
More informationC17: I/O Streams and File I/O
CISC 3120 C17: I/O Streams and File I/O Hui Chen Department of Computer & Information Science CUNY Brooklyn College 4/9/2018 CUNY Brooklyn College 1 Outline Recap and issues Review your progress Assignments:
More informationOutput Streams Input Streams Filter Streams Readers and Writers Object Streams and Serialization Introduction to Sockets
3. Java I/O Revisited Output Streams Input Streams Filter Streams Readers and Writers Object Streams and Serialization Introduction to Sockets Java I/O A large part of what network programs do is simple
More information