How do I rewrite binary data in Java
Posted
by hayato
on Stack Overflow
See other posts from Stack Overflow
or by hayato
Published on 2010-03-24T03:18:50Z
Indexed on
2010/03/24
3:23 UTC
Read the original article
Hit count: 258
java
I'm trying to figure out how to replace binary data using Java. below is a PHP example of replacing "foo" to "bar" from a swf file.
<?php
$fp = fopen("binary.swf","rb");
$size = filesize("binary.swf");
$search = bin2hex("foo");
$replace = bin2hex("bar");
$data = fread($fp, $size);
$data16 = bin2hex($data);
$data16 = str_replace($search, $replace, $data16);
$data = pack('H*',$data16);
header("Content-Type:application/x-shockwave-flash");
echo $data;
?>
How do I do this in Java.
© Stack Overflow or respective owner