public char[] getChars() throws IOException { flush(); if (inmem) { if (currentStream instanceof LoadingCharArrayWriter) { return ((LoadingCharArrayWriter)currentStream).toCharArray(); } throw new IOException("Unknown format of currentStream"); } // read the file try (Reader fin = createInputStreamReader(tempFile)) { CharArrayWriter out = new CharArrayWriter((int)tempFile.length()); char[] bytes = new char[1024]; int x = fin.read(bytes); while (x != -1) { out.write(bytes, 0, x); x = fin.read(bytes); } return out.toCharArray(); } }
public char[] getChars() throws IOException { flush(); if (inmem) { if (currentStream instanceof LoadingCharArrayWriter) { return ((LoadingCharArrayWriter)currentStream).toCharArray(); } throw new IOException("Unknown format of currentStream"); } // read the file try (Reader fin = createInputStreamReader(tempFile)) { CharArrayWriter out = new CharArrayWriter((int)tempFile.length()); char[] bytes = new char[1024]; int x = fin.read(bytes); while (x != -1) { out.write(bytes, 0, x); x = fin.read(bytes); } return out.toCharArray(); } }
public char[] getChars() throws IOException { flush(); if (inmem) { if (currentStream instanceof LoadingCharArrayWriter) { return ((LoadingCharArrayWriter)currentStream).toCharArray(); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file Reader fin = null; try { fin = createInputStreamReader(tempFile); CharArrayWriter out = new CharArrayWriter((int)tempFile.length()); char bytes[] = new char[1024]; int x = fin.read(bytes); while (x != -1) { out.write(bytes, 0, x); x = fin.read(bytes); } return out.toCharArray(); } finally { if (fin != null) { fin.close(); } } } }
public char[] getChars() throws IOException { flush(); if (inmem) { if (currentStream instanceof LoadingCharArrayWriter) { return ((LoadingCharArrayWriter)currentStream).toCharArray(); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file Reader fin = null; try { fin = createInputStreamReader(tempFile); CharArrayWriter out = new CharArrayWriter((int)tempFile.length()); char bytes[] = new char[1024]; int x = fin.read(bytes); while (x != -1) { out.write(bytes, 0, x); x = fin.read(bytes); } return out.toCharArray(); } finally { if (fin != null) { fin.close(); } } } }