private static byte[] readFully(final InputStream is) throws IOException { final TemporaryBuffer b = new TemporaryBuffer.LocalFile(); try { b.copy(is); b.close(); return b.toByteArray(); } finally { b.destroy(); } }
private String[] extractFileLines(final Charset[] csGuess) { final TemporaryBuffer[] tmp = new TemporaryBuffer[getParentCount() + 1]; try { for (int i = 0; i < tmp.length; i++) tmp[i] = new TemporaryBuffer.LocalFile(); for (final HunkHeader h : getHunks()) h.extractFileLines(tmp); final String[] r = new String[tmp.length]; for (int i = 0; i < tmp.length; i++) { Charset cs = csGuess != null ? csGuess[i] : null; if (cs == null) cs = Constants.CHARSET; r[i] = RawParseUtils.decode(cs, tmp[i].toByteArray()); } return r; } catch (IOException ioe) { throw new RuntimeException(JGitText.get().cannotConvertScriptToText, ioe); } finally { for (final TemporaryBuffer b : tmp) { if (b != null) b.destroy(); } } }