L8 - IEG4180 Tutorial 8 File IO in Different Programming...

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

View Full Document Right Arrow Icon
IEG4180 Tutorial 8 – File IO in  Different Programming  Languages; IOCP Bosco, Fong Chi Hang (Acknowledgement: some materials in this tutorial are adopted from previous works  by Shing and Zero.)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Outline Java IO File Access in C++/C I/O Completion Port
Background image of page 2
Java IO Base on concept of stream Stream of bytes InputStream / OutputStream Byte array as content Reader / Writer String as content Buffered* Improving I/O performance
Background image of page 3

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

View Full DocumentRight Arrow Icon
Java I/O Example BufferedReader br =   new BufferedReader(new FileReader(“a”)); BufferedWriter bw =   new BufferedWriter(new FileWriter(“b”)); String tmp = null; while ((tmp = br.readLine()) != null)   bw.write(tmp); bw.close(); br.close();
Background image of page 4
Java I/O Important I/O classes Remark: Buffered* can also wrap streams of socket / channel
Background image of page 5

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

View Full DocumentRight Arrow Icon
File Access in C++ CFile Class nOpenFlags Example
Background image of page 6
File Access in C+ + CFile Class CFile is a class in MFC for accessing the file CFile::CFile     //Constuctor CFile(LPCTSTR lpszFileName, UINT nOpenFlags); lpszFileName  A string that is the path to the desired file. The path can  be relative or absolute.  nOpenFlags  Sharing and access mode.
Background image of page 7

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

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

This note was uploaded on 05/18/2010 for the course INFORMATIO IEG 4180 taught by Professor Jacky.b.lee during the Spring '09 term at CUHK.

Page1 / 20

L8 - IEG4180 Tutorial 8 File IO in Different Programming...

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

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