Presentation is loading. Please wait.

Presentation is loading. Please wait.

Read and Write Files  By the end of this lab you will be able to:  Write a file in internal storage  Read a file from internal storage  Write a file.

Similar presentations


Presentation on theme: "Read and Write Files  By the end of this lab you will be able to:  Write a file in internal storage  Read a file from internal storage  Write a file."— Presentation transcript:

1 Read and Write Files  By the end of this lab you will be able to:  Write a file in internal storage  Read a file from internal storage  Write a file on SD card  Read a file from SD card  Install an app on the Android emulator CS440 1

2 Prerequisites  Main classes you will need to learn about:  BufferedReader  BufferedWriter  OutputStreamReader  OutputStreamWriter  StringBuffer  Main methods you will need to learn:  readLine!!  Write  openFileOutput  openFileInput 2

3 Java.io 3 Class Description BufferedInputStream Used for creating an internal buffer array. It supports the mark and reset methods. BufferedOutputStream Used for byte write to output stream. It implements a buffered output stream. BufferedReader Used to read text from character input stream and buffering characters. It also reads characters, arrays and lines. BufferedWriter Used to write text from character output stream and buffering characters. It also writes characters, arrays and lines.

4 Java.io 4 Class Description File Shows a file and directory pathnames. FileReader Used for reading characters in file. FileWriter Used for writing characters in file. InputStream Represents an input stream of bytes. InputStreamReader Used to read bytes and decode them into characters. OutputStream Represents an output stream of bytes. OutputStreamWriter Used to write bytes and decode them into characters.

5  Create a file in internal storage  Create all the necessary objects to write in this file BufferedWriter OutputStreamWriter  Write in the file  Read from file  Create all the necessary objects to read from this file BufferedReader OutputStreamReader CS440 5

6  How do you know you have created the file?  How do you know you have written in the file? CS440 6

7  Create a file in the SD card  Create all the necessary objects to write in this file BufferedWriter OutputStreamWriter  Write in the file  Read from file  Create all the necessary objects to read from this file BufferedReader OutputStreamReader CS440 7

8 References  http://www.vogella.de/articles/AndroidFileSystem /article.html http://www.vogella.de/articles/AndroidFileSystem /article.html  http://www.tylerfrankenstein.com/create-android- emulator-sd-card-and-write-data-to-it http://www.tylerfrankenstein.com/create-android- emulator-sd-card-and-write-data-to-it  http://stackoverflow.com/questions/9351904/cann ot-write-to-sdcard-in-android-emulator http://stackoverflow.com/questions/9351904/cann ot-write-to-sdcard-in-android-emulator CS440 8


Download ppt "Read and Write Files  By the end of this lab you will be able to:  Write a file in internal storage  Read a file from internal storage  Write a file."

Similar presentations


Ads by Google