From fc248cefa65209b11f924d7f2c6c40311ccd93c7 Mon Sep 17 00:00:00 2001 From: jjenista Date: Mon, 23 Feb 2009 23:09:59 +0000 Subject: [PATCH] Add a readLine() method --- Robust/src/ClassLibrary/FileInputStream.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Robust/src/ClassLibrary/FileInputStream.java b/Robust/src/ClassLibrary/FileInputStream.java index dbc58d4c..5a833ade 100644 --- 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); } -- 2.34.1