Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / src / javajs / util / LimitedLineReader.java
index 05ab2db..e1d973f 100644 (file)
@@ -1,48 +1,48 @@
-package javajs.util;\r
-\r
-import java.io.BufferedReader;\r
-\r
-/**\r
- *  A simple class to read a designated number of bytes from a \r
- *  file and then return them line by line, skipping lines that\r
- *  start with #, and including the \n or \r characters at line ends.\r
- *  \r
- *  Generally useful for determining what sort of data a file contains.\r
- *   \r
- */\r
-public class LimitedLineReader {\r
-  private char[] buf;\r
-  private int cchBuf;\r
-  private int ichCurrent;\r
-\r
-  public LimitedLineReader(BufferedReader bufferedReader, int readLimit)\r
-    throws Exception {  \r
-    bufferedReader.mark(readLimit + 1);\r
-    buf = new char[readLimit];\r
-    cchBuf = Math.max(bufferedReader.read(buf, 0, readLimit), 0);\r
-    ichCurrent = 0;\r
-    bufferedReader.reset();\r
-  }\r
-\r
-  public String getHeader(int n) {\r
-    return (n == 0 ? new String(buf) : new String(buf, 0, Math.min(cchBuf, n)));\r
-  }\r
-  \r
-  public String readLineWithNewline() {\r
-    while (ichCurrent < cchBuf) {\r
-      int ichBeginningOfLine = ichCurrent;\r
-      char ch = 0;\r
-      while (ichCurrent < cchBuf &&\r
-             (ch = buf[ichCurrent++]) != '\r' && ch != '\n') {\r
-      }\r
-      if (ch == '\r' && ichCurrent < cchBuf && buf[ichCurrent] == '\n')\r
-        ++ichCurrent;\r
-      int cchLine = ichCurrent - ichBeginningOfLine;\r
-      if (buf[ichBeginningOfLine] == '#')\r
-        continue; // flush comment lines;\r
-      return new String(buf, ichBeginningOfLine, cchLine);\r
-    }\r
-    return "";\r
-  }\r
-}\r
-\r
+package javajs.util;
+
+import java.io.BufferedReader;
+
+/**
+ *  A simple class to read a designated number of bytes from a 
+ *  file and then return them line by line, skipping lines that
+ *  start with #, and including the \n or \r characters at line ends.
+ *  
+ *  Generally useful for determining what sort of data a file contains.
+ *   
+ */
+public class LimitedLineReader {
+  private char[] buf;
+  private int cchBuf;
+  private int ichCurrent;
+
+  public LimitedLineReader(BufferedReader bufferedReader, int readLimit)
+    throws Exception {  
+    bufferedReader.mark(readLimit + 1);
+    buf = new char[readLimit];
+    cchBuf = Math.max(bufferedReader.read(buf, 0, readLimit), 0);
+    ichCurrent = 0;
+    bufferedReader.reset();
+  }
+
+  public String getHeader(int n) {
+    return (n == 0 ? new String(buf) : new String(buf, 0, Math.min(cchBuf, n)));
+  }
+  
+  public String readLineWithNewline() {
+    while (ichCurrent < cchBuf) {
+      int ichBeginningOfLine = ichCurrent;
+      char ch = 0;
+      while (ichCurrent < cchBuf &&
+             (ch = buf[ichCurrent++]) != '\r' && ch != '\n') {
+      }
+      if (ch == '\r' && ichCurrent < cchBuf && buf[ichCurrent] == '\n')
+        ++ichCurrent;
+      int cchLine = ichCurrent - ichBeginningOfLine;
+      if (buf[ichBeginningOfLine] == '#')
+        continue; // flush comment lines;
+      return new String(buf, ichBeginningOfLine, cchLine);
+    }
+    return "";
+  }
+}
+