james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joc...@apache.org
Subject svn commit: r954722 - /james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptor.java
Date Tue, 15 Jun 2010 06:31:14 GMT
Author: jochen
Date: Tue Jun 15 06:31:13 2010
New Revision: 954722

URL: http://svn.apache.org/viewvc?rev=954722&view=rev
Log:
Adding implementation of skip(long).

Modified:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptor.java

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptor.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptor.java?rev=954722&r1=954721&r2=954722&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptor.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptor.java
Tue Jun 15 06:31:13 2010
@@ -126,4 +126,23 @@ public class LineReaderInputStreamAdapto
 			return false;
 		}
 	}
+
+	@Override
+	public long skip(long count) throws IOException {
+		if (count <= 0) {
+			return 0; // So specified by InputStream.skip(long).
+		}
+		final int bufferSize = count > 8192 ? 8192 : (int) count;
+		final byte[] buffer = new byte[bufferSize];
+		long result = 0;
+		while (count > 0) {
+			int res = read(buffer);
+			if (res == -1) {
+				break;
+			}
+			result += res;
+			count -= res;
+		}
+		return result;
+	}
 }



Mime
View raw message