Skip to content

Instantly share code, notes, and snippets.

@akinsgre
Last active December 16, 2015 23:59
Show Gist options
  • Save akinsgre/5517259 to your computer and use it in GitHub Desktop.
Save akinsgre/5517259 to your computer and use it in GitHub Desktop.
private static InputStream addPrintCharTo(byte[] bArr)
throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.write(INIT);
// out.write(CONDENSED);
// out.write(PICA);
out.write(new Byte((byte) 0x21));
// out.write(new Byte((byte) 1));
for (int i = 0; i<bArr.length; i++) {
out.write(new byte[]{bArr[i]}, 0, 1) ;
}
byte[] outArr = out.toByteArray();
InputStream finalFile = new ByteArrayInputStream(outArr);
return finalFile;
}
private byte[] concatenate(List<File> files) throws FileNotFoundException, IOException {
PrintWriter pw = new PrintWriter(new FileOutputStream(Utils.TMP_DIR + "concat.txt"));
ByteArrayOutputStream out = new ByteArrayOutputStream();
for (File file : files) {
System.out.println("Processing " + file.getPath() + "... ");
BufferedReader br = new BufferedReader(new FileReader(file.getPath()));
String line = br.readLine();
while (line != null) {
out.write(line.getBytes());
line = br.readLine();
}
br.close();
}
byte[] bArr = out.toByteArray();
pw.close();
return bArr ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment