private synchronized InputStream openInputStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return new ByteArrayInputStream(memory.getBuffer(), 0, memory.getCount()); } }
/** * Checks if writing {@code len} bytes would go over threshold, and switches to file buffering if * so. */ private void update(int len) throws IOException { if (file == null && (memory.getCount() + len > fileThreshold)) { File temp = File.createTempFile("FileBackedOutputStream", null); if (resetOnFinalize) { // Finalizers are not guaranteed to be called on system shutdown; // this is insurance. temp.deleteOnExit(); } FileOutputStream transfer = new FileOutputStream(temp); transfer.write(memory.getBuffer(), 0, memory.getCount()); transfer.flush(); // We've successfully transferred the data; switch to writing to file out = transfer; file = temp; memory = null; } } }
/** * Checks if writing {@code len} bytes would go over threshold, and switches to file buffering if * so. */ private void update(int len) throws IOException { if (file == null && (memory.getCount() + len > fileThreshold)) { File temp = File.createTempFile("FileBackedOutputStream", null); if (resetOnFinalize) { // Finalizers are not guaranteed to be called on system shutdown; // this is insurance. temp.deleteOnExit(); } FileOutputStream transfer = new FileOutputStream(temp); transfer.write(memory.getBuffer(), 0, memory.getCount()); transfer.flush(); // We've successfully transferred the data; switch to writing to file out = transfer; file = temp; memory = null; } } }
/** * Checks if writing {@code len} bytes would go over threshold, and * switches to file buffering if so. */ private void update(int len) throws IOException { if (file == null && (memory.getCount() + len > fileThreshold)) { File temp = File.createTempFile("FileBackedOutputStream", null); if (resetOnFinalize) { // Finalizers are not guaranteed to be called on system shutdown; // this is insurance. temp.deleteOnExit(); } FileOutputStream transfer = new FileOutputStream(temp); transfer.write(memory.getBuffer(), 0, memory.getCount()); transfer.flush(); // We've successfully transferred the data; switch to writing to file out = transfer; file = temp; memory = null; } } }
/** * Checks if writing {@code len} bytes would go over threshold, and * switches to file buffering if so. */ private void update(int len) throws IOException { if (file == null && (memory.getCount() + len > fileThreshold)) { File temp = File.createTempFile("FileBackedOutputStream", null); if (resetOnFinalize) { // Finalizers are not guaranteed to be called on system shutdown; // this is insurance. temp.deleteOnExit(); } FileOutputStream transfer = new FileOutputStream(temp); transfer.write(memory.getBuffer(), 0, memory.getCount()); transfer.flush(); // We've successfully transferred the data; switch to writing to file out = transfer; file = temp; memory = null; } } }
private synchronized InputStream openStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return new ByteArrayInputStream( memory.getBuffer(), 0, memory.getCount()); } }
private synchronized InputStream openInputStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return new ByteArrayInputStream( memory.getBuffer(), 0, memory.getCount()); } }
private synchronized InputStream openInputStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return new ByteArrayInputStream( memory.getBuffer(), 0, memory.getCount()); } }
private synchronized InputStream openInputStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return new ByteArrayInputStream( memory.getBuffer(), 0, memory.getCount()); } }
private synchronized InputStream openStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return new ByteArrayInputStream( memory.getBuffer(), 0, memory.getCount()); } }
private synchronized InputStream openInputStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return new ByteArrayInputStream( memory.getBuffer(), 0, memory.getCount()); } }
private synchronized InputStream openInputStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return new ByteArrayInputStream( memory.getBuffer(), 0, memory.getCount()); } }
private synchronized InputStream openInputStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return new ByteArrayInputStream(memory.getBuffer(), 0, memory.getCount()); } }
private synchronized InputStream openStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return new ByteArrayInputStream( memory.getBuffer(), 0, memory.getCount()); } }
private synchronized InputStream openInputStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return new ByteArrayInputStream( memory.getBuffer(), 0, memory.getCount()); } }
private synchronized InputStream openInputStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return new ByteArrayInputStream(memory.getBuffer(), 0, memory.getCount()); } }
private synchronized InputStream openStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return new ByteArrayInputStream( memory.getBuffer(), 0, memory.getCount()); } }
/** * Checks if writing {@code len} bytes would go over threshold, and switches to file buffering if * so. */ private void update(int len) throws IOException { if (file == null && (memory.getCount() + len > fileThreshold)) { File temp = File.createTempFile("FileBackedOutputStream", null); if (resetOnFinalize) { // Finalizers are not guaranteed to be called on system shutdown; // this is insurance. temp.deleteOnExit(); } FileOutputStream transfer = new FileOutputStream(temp); transfer.write(memory.getBuffer(), 0, memory.getCount()); transfer.flush(); // We've successfully transferred the data; switch to writing to file out = transfer; file = temp; memory = null; } } }
private synchronized InputStream openInputStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return new ByteArrayInputStream(memory.getBuffer(), 0, memory.getCount()); } }
private synchronized InputStream openInputStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return new ByteArrayInputStream(memory.getBuffer(), 0, memory.getCount()); } }