Coverage Report - org.jaudiotagger.audio.asf.io.RandomAccessFileInputstream
 
Classes in this File Line Coverage Branch Coverage Complexity
RandomAccessFileInputstream
69%
9/13
50%
3/6
0
 
 1  
 package org.jaudiotagger.audio.asf.io;
 2  
 
 3  
 import java.io.IOException;
 4  
 import java.io.InputStream;
 5  
 import java.io.RandomAccessFile;
 6  
 
 7  
 /**
 8  
  * Wraps a {@link RandomAccessFile} into an {@link InputStream}.<br>
 9  
  * @author Christian Laireiter
 10  
  */
 11  
 public final class RandomAccessFileInputstream extends InputStream
 12  
 {
 13  
 
 14  
     /**
 15  
      * The file access to read from.<br>
 16  
      */
 17  
     private final RandomAccessFile source;
 18  
 
 19  
     /**
 20  
      * Creates an instance that will provide {@link InputStream} functionality on the given
 21  
      * {@link RandomAccessFile} by delegating calls.<br>
 22  
      * 
 23  
      * @param file The file to read.
 24  
      */
 25  
     public RandomAccessFileInputstream(final RandomAccessFile file)
 26  50
     {
 27  50
         if (file == null)
 28  
         {
 29  0
             throw new NullPointerException();
 30  
         }
 31  50
         this.source = file;
 32  50
     }
 33  
 
 34  
     /**
 35  
      * {@inheritDoc}
 36  
      */
 37  
     @Override
 38  
     public int read() throws IOException
 39  
     {
 40  4398
         return this.source.read();
 41  
     }
 42  
 
 43  
     /**
 44  
      * {@inheritDoc}
 45  
      */
 46  
     @Override
 47  
     public int read(byte[] b, int off, int len) throws IOException
 48  
     {
 49  2947
         return this.source.read(b, off, len);
 50  
     }
 51  
 
 52  
    /**
 53  
      * {@inheritDoc}
 54  
      */
 55  
     @Override
 56  
     public long skip(long n) throws IOException
 57  
     {
 58  28
         if (n <= 0)
 59  
         {
 60  0
             return 0;
 61  
         }
 62  28
         while (n > Integer.MAX_VALUE)
 63  
         {
 64  0
             this.source.skipBytes(Integer.MAX_VALUE);
 65  0
             n -= Integer.MAX_VALUE;
 66  
         }
 67  28
         return this.source.skipBytes((int) n);
 68  
     }
 69  
 
 70  
 }