projects
/
IRC.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ab2747a
)
Add a readLine() method
author
jjenista
<jjenista>
Mon, 23 Feb 2009 23:09:59 +0000
(23:09 +0000)
committer
jjenista
<jjenista>
Mon, 23 Feb 2009 23:09:59 +0000
(23:09 +0000)
Robust/src/ClassLibrary/FileInputStream.java
patch
|
blob
|
history
diff --git
a/Robust/src/ClassLibrary/FileInputStream.java
b/Robust/src/ClassLibrary/FileInputStream.java
index dbc58d4cdca38c44f45cbe80dbef23c6c2ef8c86..5a833ade1948c8a3e5e19988059cebbfcb24da5a 100644
(file)
--- a/
Robust/src/ClassLibrary/FileInputStream.java
+++ b/
Robust/src/ClassLibrary/FileInputStream.java
@@
-28,6
+28,24
@@
public class FileInputStream extends InputStream {
return nativeRead(fd, b, b.length);
}
+ public String readLine() {
+ String line = "";
+ int c = read();
+
+ // if we're already at the end of the file
+ // don't even return the empty string
+ if( c == -1 ) {
+ return null;
+ }
+
+ while( c != '\n' && c != -1 ) {
+ line += (char)c;
+ c = read();
+ }
+
+ return line;
+ }
+
public void close() {
nativeClose(fd);
}