How do I rewrite binary data in Java
<p>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.</p>

<pre><code>&lt;?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;
?&gt;
</code></pre>

<p>How do I do this in Java.</p>
