Skip to content

Instantly share code, notes, and snippets.

@mccxj
Created February 6, 2013 13:39
Show Gist options
  • Save mccxj/4722548 to your computer and use it in GitHub Desktop.
Save mccxj/4722548 to your computer and use it in GitHub Desktop.
public static void main(String[] args) throws Exception {
File file = new File("test.txt");
FileInputStream is = new FileInputStream(file);
FileOutputStream os = new FileOutputStream("test.7z");
int k;
char[] ka = new char[2];
int i=0;
while((k = is.read()) != -1)
{
ka[i++] = (char)k;
if(i==2)
{
int s = Integer.parseInt(new String(ka), 16);
os.write(s);
i = 0;
}
}
//ignore exception handle
os.close();
is.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment