public void writeCacheTo(Writer out) throws IOException { flush(); if (inmem) { if (currentStream instanceof LoadingCharArrayWriter) { ((LoadingCharArrayWriter)currentStream).writeTo(out); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file try (Reader fin = createInputStreamReader(tempFile)) { char[] bytes = new char[1024]; int x = fin.read(bytes); while (x != -1) { out.write(bytes, 0, x); x = fin.read(bytes); } } } }
public void writeCacheTo(Writer out) throws IOException { flush(); if (inmem) { if (currentStream instanceof LoadingCharArrayWriter) { ((LoadingCharArrayWriter)currentStream).writeTo(out); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file Reader fin = null; try { fin = createInputStreamReader(tempFile); char bytes[] = new char[1024]; int x = fin.read(bytes); while (x != -1) { out.write(bytes, 0, x); x = fin.read(bytes); } } finally { if (fin != null) { fin.close(); } } } }
public void writeCacheTo(Writer out) throws IOException { flush(); if (inmem) { if (currentStream instanceof LoadingCharArrayWriter) { ((LoadingCharArrayWriter)currentStream).writeTo(out); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file try (Reader fin = createInputStreamReader(tempFile)) { char[] bytes = new char[1024]; int x = fin.read(bytes); while (x != -1) { out.write(bytes, 0, x); x = fin.read(bytes); } } } }
LoadingCharArrayWriter byteOut = (LoadingCharArrayWriter) currentStream; if (copyOldContent && byteOut.size() > 0) { byteOut.writeTo(out);
LoadingCharArrayWriter byteOut = (LoadingCharArrayWriter) currentStream; if (copyOldContent && byteOut.size() > 0) { byteOut.writeTo(out);
LoadingCharArrayWriter byteOut = (LoadingCharArrayWriter) currentStream; if (copyOldContent && byteOut.size() > 0) { byteOut.writeTo(out);
LoadingCharArrayWriter byteOut = (LoadingCharArrayWriter) currentStream; if (copyOldContent && byteOut.size() > 0) { byteOut.writeTo(out);
private void createFileOutputStream() throws IOException { if (tempFileFailed) { return; } LoadingCharArrayWriter bout = (LoadingCharArrayWriter)currentStream; try { if (outputDir == null) { tempFile = FileUtils.createTempFile("cos", "tmp"); } else { tempFile = FileUtils.createTempFile("cos", "tmp", outputDir, false); } currentStream = createOutputStreamWriter(tempFile); bout.writeTo(currentStream); inmem = false; streamList.add(currentStream); } catch (Exception ex) { //Could be IOException or SecurityException or other issues. //Don't care what, just keep it in memory. tempFileFailed = true; if (currentStream != bout) { currentStream.close(); } deleteTempFile(); inmem = true; currentStream = bout; } }
public void writeCacheTo(Writer out) throws IOException { flush(); if (inmem) { if (currentStream instanceof LoadingCharArrayWriter) { ((LoadingCharArrayWriter)currentStream).writeTo(out); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file Reader fin = null; try { fin = createInputStreamReader(tempFile); char bytes[] = new char[1024]; int x = fin.read(bytes); while (x != -1) { out.write(bytes, 0, x); x = fin.read(bytes); } } finally { if (fin != null) { fin.close(); } } } }
private void createFileOutputStream() throws IOException { if (tempFileFailed) { return; } LoadingCharArrayWriter bout = (LoadingCharArrayWriter)currentStream; try { if (outputDir == null) { tempFile = FileUtils.createTempFile("cos", "tmp"); } else { tempFile = FileUtils.createTempFile("cos", "tmp", outputDir, false); } currentStream = createOutputStreamWriter(tempFile); bout.writeTo(currentStream); inmem = false; streamList.add(currentStream); } catch (Exception ex) { //Could be IOException or SecurityException or other issues. //Don't care what, just keep it in memory. tempFileFailed = true; if (currentStream != bout) { currentStream.close(); } deleteTempFile(); inmem = true; currentStream = bout; } }
private void createFileOutputStream() throws IOException { if (tempFileFailed) { return; } LoadingCharArrayWriter bout = (LoadingCharArrayWriter)currentStream; try { if (outputDir == null) { tempFile = FileUtils.createTempFile("cos", "tmp"); } else { tempFile = FileUtils.createTempFile("cos", "tmp", outputDir, false); } currentStream = createOutputStreamWriter(tempFile); bout.writeTo(currentStream); inmem = false; streamList.add(currentStream); } catch (Exception ex) { //Could be IOException or SecurityException or other issues. //Don't care what, just keep it in memory. tempFileFailed = true; if (currentStream != bout) { currentStream.close(); } deleteTempFile(); inmem = true; currentStream = bout; } }
private void createFileOutputStream() throws IOException { if (tempFileFailed) { return; } LoadingCharArrayWriter bout = (LoadingCharArrayWriter)currentStream; try { if (outputDir == null) { tempFile = FileUtils.createTempFile("cos", "tmp"); } else { tempFile = FileUtils.createTempFile("cos", "tmp", outputDir, false); } currentStream = createOutputStreamWriter(tempFile); bout.writeTo(currentStream); inmem = false; streamList.add(currentStream); } catch (Exception ex) { //Could be IOException or SecurityException or other issues. //Don't care what, just keep it in memory. tempFileFailed = true; if (currentStream != bout) { currentStream.close(); } deleteTempFile(); inmem = true; currentStream = bout; } }