| 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 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
public final class RandomAccessFileInputstream extends InputStream |
| 12 | |
{ |
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
private final RandomAccessFile source; |
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 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 | |
|
| 36 | |
|
| 37 | |
@Override |
| 38 | |
public int read() throws IOException |
| 39 | |
{ |
| 40 | 4398 | return this.source.read(); |
| 41 | |
} |
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 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 | |
|
| 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 | |
} |