should use BufferedReader class instead of DataInputStream.
--- NoteEditor.java-1.1.3 2009-11-30 13:40:42.937500000 +0900
+++ NoteEditor.java 2009-11-30 16:43:38.354375000 +0900
@@ -23,8 +23,8 @@
package org.openintents.notepad;
-import java.io.BufferedInputStream;
-import java.io.DataInputStream;
+import java.io.InputStreamReader;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -352,31 +352,28 @@
public String readFile(File file) {
FileInputStream fis = null;
- BufferedInputStream bis = null;
- DataInputStream dis = null;
+ BufferedReader dis = null;
StringBuffer sb = new StringBuffer();
try {
fis = new FileInputStream(file);
// Here BufferedInputStream is added for fast reading.
- bis = new BufferedInputStream(fis);
- dis = new DataInputStream(bis);
+ dis = new BufferedReader(new InputStreamReader(fis));
// dis.available() returns 0 if the file does not have more lines.
- while (dis.available() != 0) {
+ while (dis.ready()) {
// this statement reads the line from the file and print it to
// the console.
sb.append(dis.readLine());
- if (dis.available() != 0) {
+ if (dis.ready()) {
sb.append("\n");
}
}
// dispose all the resources after using them.
fis.close();
- bis.close();
dis.close();
} catch (FileNotFoundException e) {