commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roxspr...@apache.org
Subject svn commit: r160202 - in jakarta/commons/proper/io/trunk: project.xml src/java/org/apache/commons/io/input/CountingInputStream.java src/test/org/apache/commons/io/input/CountingInputStreamTest.java
Date Tue, 05 Apr 2005 17:22:22 GMT
Author: roxspring
Date: Tue Apr  5 10:22:21 2005
New Revision: 160202

URL: http://svn.apache.org/viewcvs?view=rev&rev=160202
Log:
CountingInputStream now implements skip(long) method.
PR: 34311

Modified:
    jakarta/commons/proper/io/trunk/project.xml
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/CountingInputStream.java
    jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/CountingInputStreamTest.java

Modified: jakarta/commons/proper/io/trunk/project.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/project.xml?view=diff&r1=160201&r2=160202
==============================================================================
--- jakarta/commons/proper/io/trunk/project.xml (original)
+++ jakarta/commons/proper/io/trunk/project.xml Tue Apr  5 10:22:21 2005
@@ -16,7 +16,7 @@
 -->
 <project>
   <pomVersion>3</pomVersion>
-  
+
   <name>IO</name>
   <id>commons-io</id>
   <currentVersion>1.1-dev</currentVersion>
@@ -26,7 +26,7 @@
         Commons-IO contains utility classes, stream implementations, file filters, and endian
classes.
   </description>
   <logo>/images/io-logo-white.png</logo>
-  
+
   <url>http://jakarta.apache.org/commons/${pom.artifactId.substring(8)}/</url>
   <package>org.apache.commons.${pom.artifactId.substring(8)}</package>
 
@@ -43,18 +43,18 @@
       <distribution>repo</distribution>
     </license>
   </licenses>
-  
+
   <gumpRepositoryId>jakarta</gumpRepositoryId>
   <issueTrackingUrl>http://issues.apache.org/bugzilla/</issueTrackingUrl>
   <siteAddress>jakarta.apache.org</siteAddress>
   <siteDirectory>/www/jakarta.apache.org/commons/${pom.artifactId.substring(8)}/</siteDirectory>
   <distributionDirectory>/www/jakarta.apache.org/builds/jakarta-commons/${pom.artifactId.substring(8)}/</distributionDirectory>
-  
+
   <repository>
     <connection>scm:svn:http://svn.apache.org/repos/asf/jakarta/commons/proper/${pom.artifactId.substring(8)}/trunk</connection>
     <url>http://svn.apache.org/repos/asf/jakarta/commons/proper/${pom.artifactId.substring(8)}/trunk</url>
   </repository>
-  
+
   <mailingLists>
     <mailingList>
       <name>Commons Dev List</name>
@@ -69,7 +69,7 @@
       <archive>http://mail-archives.apache.org/eyebrowse/SummarizeList?listName=commons-user@jakarta.apache.org</archive>
     </mailingList>
   </mailingLists>
-  
+
   <versions>
     <version>
       <id>1.0</id>
@@ -146,6 +146,15 @@
       <name>Martin Cooper</name>
       <id>martinc</id>
       <email>martinc@apache.org</email>
+      <organization/>
+      <roles>
+        <role>Java Developer</role>
+      </roles>
+    </developer>
+    <developer>
+      <name>Rob Oxspring</name>
+      <id>roxspring</id>
+      <email>roxspring@apache.org</email>
       <organization/>
       <roles>
         <role>Java Developer</role>

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/CountingInputStream.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/CountingInputStream.java?view=diff&r1=160201&r2=160202
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/CountingInputStream.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/CountingInputStream.java
Tue Apr  5 10:22:21 2005
@@ -71,6 +71,17 @@
         this.count += (found >= 0) ? 1 : 0;
         return found;
     }
+    
+    /**
+     * Increases the count by the number of skipped bytes.
+     * 
+     * @see java.io.InputStream#skip(long)
+     */
+    public long skip(final long length) throws IOException {
+        final long skip = super.skip(length);
+        this.count += skip;
+        return skip;
+    }
 
     /**
      * The number of bytes that have passed through this stream.

Modified: jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/CountingInputStreamTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/CountingInputStreamTest.java?view=diff&r1=160201&r2=160202
==============================================================================
--- jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/CountingInputStreamTest.java
(original)
+++ jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/CountingInputStreamTest.java
Tue Apr  5 10:22:21 2005
@@ -17,6 +17,8 @@
 package org.apache.commons.io.input;
 
 import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Arrays;
 
 import junit.framework.TestCase;
 
@@ -148,6 +150,21 @@
         int found = cis.read(result, 0, 5);
         assertEquals(2, found);
         assertEquals(2, cis.getCount());
+    }
+    
+    public void testSkipping() throws IOException {
+        String text = "Hello World!";
+        byte[] bytes = text.getBytes();
+        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+        CountingInputStream cis = new CountingInputStream(bais);
+        
+        assertEquals(6,cis.skip(6));
+        assertEquals(6,cis.getCount());
+        final byte[] result = new byte[6];
+        cis.read(result);
+        
+        assertEquals("World!",new String(result));
+        assertEquals(12,cis.getCount());
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message