public byte[] getBytes() throws IOException { flush(); if (inmem) { if (currentStream instanceof ByteArrayOutputStream) { return ((ByteArrayOutputStream)currentStream).toByteArray(); } throw new IOException("Unknown format of currentStream"); } // read the file try (InputStream fin = createInputStream(tempFile)) { return IOUtils.readBytesFromStream(fin); } }
public byte[] getBytes() throws IOException { flush(); if (inmem) { if (currentStream instanceof ByteArrayOutputStream) { return ((ByteArrayOutputStream)currentStream).toByteArray(); } throw new IOException("Unknown format of currentStream"); } // read the file try (InputStream fin = createInputStream(tempFile)) { return IOUtils.readBytesFromStream(fin); } }
public void writeCacheTo(OutputStream out) throws IOException { flush(); if (inmem) { if (currentStream instanceof ByteArrayOutputStream) { ((ByteArrayOutputStream)currentStream).writeTo(out); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file InputStream fin = createInputStream(tempFile); IOUtils.copyAndCloseInput(fin, out); } }
public byte[] getBytes() throws IOException { flush(); if (inmem) { if (currentStream instanceof ByteArrayOutputStream) { return ((ByteArrayOutputStream)currentStream).toByteArray(); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file InputStream fin = createInputStream(tempFile); return IOUtils.readBytesFromStream(fin); } }
public void writeCacheTo(OutputStream out) throws IOException { flush(); if (inmem) { if (currentStream instanceof ByteArrayOutputStream) { ((ByteArrayOutputStream)currentStream).writeTo(out); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file InputStream fin = createInputStream(tempFile); IOUtils.copyAndCloseInput(fin, out); } }
public void writeCacheTo(OutputStream out) throws IOException { flush(); if (inmem) { if (currentStream instanceof ByteArrayOutputStream) { ((ByteArrayOutputStream)currentStream).writeTo(out); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file InputStream fin = createInputStream(tempFile); IOUtils.copyAndCloseInput(fin, out); } }
public byte[] getBytes() throws IOException { flush(); if (inmem) { if (currentStream instanceof ByteArrayOutputStream) { return ((ByteArrayOutputStream)currentStream).toByteArray(); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file InputStream fin = createInputStream(tempFile); return IOUtils.readBytesFromStream(fin); } }
public void writeCacheTo(OutputStream out) throws IOException { flush(); if (inmem) { if (currentStream instanceof ByteArrayOutputStream) { ((ByteArrayOutputStream)currentStream).writeTo(out); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file InputStream fin = createInputStream(tempFile); IOUtils.copyAndCloseInput(fin, out); } }
public void writeCacheTo(StringBuilder out, String charsetName) throws IOException { flush(); if (inmem) { if (currentStream instanceof LoadingByteArrayOutputStream) { LoadingByteArrayOutputStream lout = (LoadingByteArrayOutputStream)currentStream; out.append(IOUtils.newStringFromBytes(lout.getRawBytes(), charsetName, 0, lout.size())); } else if (currentStream instanceof ByteArrayOutputStream) { byte[] bytes = ((ByteArrayOutputStream)currentStream).toByteArray(); out.append(IOUtils.newStringFromBytes(bytes, charsetName)); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file try (InputStream fin = createInputStream(tempFile); Reader reader = new InputStreamReader(fin, charsetName)) { char[] bytes = new char[1024]; int x = reader.read(bytes); while (x != -1) { out.append(bytes, 0, x); x = reader.read(bytes); } } } }
public void writeCacheTo(StringBuilder out, String charsetName) throws IOException { flush(); if (inmem) { if (currentStream instanceof LoadingByteArrayOutputStream) { LoadingByteArrayOutputStream lout = (LoadingByteArrayOutputStream)currentStream; out.append(IOUtils.newStringFromBytes(lout.getRawBytes(), charsetName, 0, lout.size())); } else if (currentStream instanceof ByteArrayOutputStream) { byte[] bytes = ((ByteArrayOutputStream)currentStream).toByteArray(); out.append(IOUtils.newStringFromBytes(bytes, charsetName)); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file try (InputStream fin = createInputStream(tempFile); Reader reader = new InputStreamReader(fin, charsetName)) { char[] bytes = new char[1024]; int x = reader.read(bytes); while (x != -1) { out.append(bytes, 0, x); x = reader.read(bytes); } } } }
Reader reader = null; try { fin = createInputStream(tempFile); reader = new InputStreamReader(fin, charsetName); char bytes[] = new char[1024];
Reader reader = null; try { fin = createInputStream(tempFile); reader = new InputStreamReader(fin, charsetName); char bytes[] = new char[1024];
try (InputStream fin = createInputStream(tempFile); Reader reader = new InputStreamReader(fin, charsetName)) { char[] bytes = new char[1024];
try (InputStream fin = createInputStream(tempFile); Reader reader = new InputStreamReader(fin, charsetName)) { char[] bytes = new char[1024];
Reader reader = null; try { fin = createInputStream(tempFile); reader = new InputStreamReader(fin, charsetName); char bytes[] = new char[1024];
Reader reader = null; try { fin = createInputStream(tempFile); reader = new InputStreamReader(fin, charsetName); char bytes[] = new char[1024];
currentStream.close(); if (copyOldContent) { InputStream fin = createInputStream(tempFile); IOUtils.copyAndCloseInput(fin, out);
currentStream.close(); if (copyOldContent) { InputStream fin = createInputStream(tempFile); IOUtils.copyAndCloseInput(fin, out);
InputStream fin = createInputStream(tempFile); IOUtils.copyAndCloseInput(fin, out);
InputStream fin = createInputStream(tempFile); IOUtils.copyAndCloseInput(fin, out);