1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-11 03:45:06 -05:00
filebot/source/net/sourceforge/tuned/ByteBufferInputStream.java
Reinhard Pointner aefc84085b * split ExportHandler interface into TransferableExportHandler and FileExportHandler
* added string flavour to all text transfer operations
* text file for dnd transfer will only be created on demand

* removed ImportHandler interface

* moved sfv renderer classes to sfv package
* removed sfv renderer package

* rename-lists now titled "Proposed" and "Current"

* DefaultClipboardHandler will export null values as empty string, not "null"
* refactored OpenSubtitlesHasher

* adapted to the new tvrage episode list xml feed syntax
2008-10-06 19:13:58 +00:00

66 lines
1.0 KiB
Java

package net.sourceforge.tuned;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
public class ByteBufferInputStream extends InputStream {
private final ByteBuffer buffer;
public ByteBufferInputStream(ByteBuffer buffer) {
this.buffer = buffer;
}
@Override
public synchronized int read() throws IOException {
if (buffer.remaining() <= 0)
return -1;
return buffer.get();
}
@Override
public synchronized int read(byte[] b, int off, int len) throws IOException {
if (buffer.remaining() <= 0)
return -1;
int length = Math.min(len, buffer.remaining());
buffer.get(b, off, length);
return length;
}
@Override
public synchronized int available() throws IOException {
return buffer.remaining();
}
@Override
public boolean markSupported() {
return true;
}
@Override
public synchronized void mark(int readlimit) {
buffer.mark();
}
@Override
public synchronized void reset() throws IOException {
buffer.reset();
}
}