added getLocalAddress() and print()
[org.ibex.io.git] / src / org / ibex / io / Stream.java
index 0732016..51fe9f6 100644 (file)
@@ -54,10 +54,11 @@ public class Stream {
     public void   unread(String s)                 { in.unread(s); }
 
     public void   println()                        { println(""); }
-    public void   println(String s)                { logWrite(s); out.write(s); out.write(newLine); }
+    public void   print(String s)                  { logWrite(s); out.write(s); flush(); }
+    public void   println(String s)                { logWrite(s); out.write(s); out.write(newLine); flush(); }
 
     public void   flush()                          { if (out != null) try { out.w.flush(); } catch(IOException e) { ioe(e); } }
-    public void   close()                          { in.close(); out.close(); }
+    public void   close()                          { try { in.close(); } finally { out.close(); } }
     public void   setNewline(String s)             { newLine = s; }
 
 
@@ -114,7 +115,7 @@ public class Stream {
                         int len = i-cstart;
                         cstart = i+1;
                         if (cbuf[begin] == '\r') { begin++; len--; }
-                        if (len > 0 && cbuf[begin+len-1] == '\r') { len--; }
+                        while (len > 0 && cbuf[begin+len-1] == '\r') { len--; }
                         return new String(cbuf, begin, len);
                     }
                 ensurec(256);