Created
July 11, 2015 18:18
-
-
Save octylFractal/827d7fd804df6cb34c4c to your computer and use it in GitHub Desktop.
This file contains 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
import java.io.*; | |
import java.nio.*; | |
import java.nio.file.*; | |
public class Encode { | |
private static final byte INIT_BYTE = (byte) 0x17; | |
private static final byte ESCAPE_BYTE = (byte) 0x18; | |
private static final byte EXIT_BYTE = (byte) 0x19; | |
public static void main(String[] args) throws Exception { | |
try (InputStream in = System.in; OutputStream out = Files.newOutputStream(Paths.get("./encoded.jar"))) { | |
int read = -1; | |
out.write(INIT_BYTE); | |
while ((read = in.read()) != -1) { | |
if (read == INIT_BYTE || read == ESCAPE_BYTE || read == EXIT_BYTE) { | |
out.write(ESCAPE_BYTE); | |
} | |
out.write(read); | |
} | |
out.write(EXIT_BYTE); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment