Author: nextgens
Date: 2008-08-25 21:43:49 +0000 (Mon, 25 Aug 2008)
New Revision: 22154

Modified:
   trunk/freenet/src/freenet/support/io/TempBucketFactory.java
Log:
TempBucket: implement read(byte[], int, int)

Modified: trunk/freenet/src/freenet/support/io/TempBucketFactory.java
===================================================================
--- trunk/freenet/src/freenet/support/io/TempBucketFactory.java 2008-08-25 
21:36:32 UTC (rev 22153)
+++ trunk/freenet/src/freenet/support/io/TempBucketFactory.java 2008-08-25 
21:43:49 UTC (rev 22154)
@@ -193,7 +193,10 @@
                                synchronized(currentBucket) {
                                        _maybeMigrateRamBucket(currentSize);
                                        _maybeResetOutputStream();
-                                       Closer.close(currentOS);
+                                       if(currentOS != null) {
+                                               currentOS.flush();
+                                               Closer.close(currentOS);
+                                       }
                                }
                        }
                }
@@ -228,6 +231,22 @@
                        }

                        @Override
+                       public int read(byte b[]) throws IOException {
+                               return read(b, 0, b.length);
+                       }
+                       
+                       @Override
+                       public int read(byte b[], int off, int len) throws 
IOException {
+                               synchronized(currentBucket) {
+                                       _maybeResetInputStream();
+                                       int toReturn = currentIS.read(b, off, 
len);
+                                       if(toReturn > -1)
+                                               index += len;
+                                       return toReturn;
+                               }
+                       }
+                       
+                       @Override
                        public long skip(long n) throws IOException {
                                synchronized(currentBucket) {
                                        _maybeResetInputStream();


Reply via email to