public ReadAllStream() { memStream = new MemoryStream(); fileStream = new FileStream(); }
@Override public void close() throws IOException { if (!closed) { memStream.close(); fileStream.close(); closed = true; } }
@Override public int read(byte b[], int off, int sz) throws IOException { int len = memStream.read(b, off, sz); if (len == -1) { len = fileStream.read(b, off, sz); } return len; }
/** * Reads the data from input stream completely. It keeps * inMemory size in the memory, and the rest on the file * system. * * Caller's responsibility to close the InputStream. This * method can be called only once. * * @param in from which to be read * @param inMemory this much data is kept in the memory * @throws IOException in case of exception */ public void readAll(InputStream in, long inMemory) throws IOException { assert !readAll; readAll = true; boolean eof = memStream.readAll(in, inMemory); if (!eof) { fileStream.readAll(in); } }
/** * Reads the data from input stream completely. It keeps * inMemory size in the memory, and the rest on the file * system. * * Caller's responsibility to close the InputStream. This * method can be called only once. * * @param in from which to be read * @param inMemory this much data is kept in the memory * @throws IOException in case of exception */ public void readAll(InputStream in, long inMemory) throws IOException { assert !readAll; readAll = true; boolean eof = memStream.readAll(in, inMemory); if (!eof) { fileStream.readAll(in); } }
/** * Reads the data from input stream completely. It keeps * inMemory size in the memory, and the rest on the file * system. * * Caller's responsibility to close the InputStream. This * method can be called only once. * * @param in from which to be read * @param inMemory this much data is kept in the memory * @throws IOException in case of exception */ public void readAll(InputStream in, long inMemory) throws IOException { assert !readAll; readAll = true; boolean eof = memStream.readAll(in, inMemory); if (!eof) { fileStream.readAll(in); } }
public ReadAllStream() { memStream = new MemoryStream(); fileStream = new FileStream(); }
public ReadAllStream() { memStream = new MemoryStream(); fileStream = new FileStream(); }
@Override public int read() throws IOException { int ch = memStream.read(); if (ch == -1) { ch = fileStream.read(); } return ch; }
@Override public void close() throws IOException { if (!closed) { memStream.close(); fileStream.close(); closed = true; } }
@Override public int read(byte b[], int off, int sz) throws IOException { int len = memStream.read(b, off, sz); if (len == -1) { len = fileStream.read(b, off, sz); } return len; }
@Override public int read(byte b[], int off, int sz) throws IOException { int len = memStream.read(b, off, sz); if (len == -1) { len = fileStream.read(b, off, sz); } return len; }
@Override public int read() throws IOException { int ch = memStream.read(); if (ch == -1) { ch = fileStream.read(); } return ch; }
@Override public int read() throws IOException { int ch = memStream.read(); if (ch == -1) { ch = fileStream.read(); } return ch; }
@Override public void close() throws IOException { if (!closed) { memStream.close(); fileStream.close(); closed = true; } }