Last active
December 16, 2015 23:59
-
-
Save akinsgre/5517259 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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