title: Perl's pack function equivalent in Java
body: <p>I have some Perl code that I need to transpose in Java. In this code I have to deal with Perl's <a href="http://perldoc.perl.org/functions/pack.html" rel="nofollow noreferrer"><code>pack</code></a>. Is there an equivalent function in Java? The Perl code looks something like this:</p>
  
  <pre><code>$somevar = pack "H*", $vartopack;
  </code></pre>