user3408: I want to use this tool: http://blockchain.info/pushtx to push transaction. I don't understand the input data. It says it is hex string representation. I've read information about that in the raw transaction of the RPC API, but I am working with bitcoinj, it there a way to get this hex string ?
Thank you
EDIT: I want to do that to compose and broadcast a transaction
For now I did this:
final StringBuilder sb = new StringBuilder();
Formatter formatter = new Formatter(sb);
try {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    transaction.bitcoinSerialize(os);
    byte[] bytes = os.toByteArray();
    for (byte b : bytes) {
        formatter.format("%02x", b);  
    }

    return sb.toString();
}catch (IOException e) {
    return "Couldn't serialize to hex string.";
} finally {
    formatter.close();
}


user19331: A shorter version could be:
String hex = DatatypeConverter.printHexBinary(tx.unsafeBitcoinSerialize());

Where the hex converter used is standard at least since Java 7:
http://docs.oracle.com/javase/7/docs/api/javax/xml/bind/DatatypeConverter.html

3408: <p>I want to use this tool: <a href="http://blockchain.info/pushtx" rel="nofollow">http://blockchain.info/pushtx</a> to push transaction. I don't understand the input data. It says it is hex string representation. I've read information about that in the raw transaction of the RPC API, but I am working with bitcoinj, it there a way to get this hex string ?</p>

<p>Thank you</p>

<p>EDIT: I want to do that to compose and broadcast a transaction</p>

<p>For now I did this:</p>

<pre><code>final StringBuilder sb = new StringBuilder();
Formatter formatter = new Formatter(sb);
try {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    transaction.bitcoinSerialize(os);
    byte[] bytes = os.toByteArray();
    for (byte b : bytes) {
        formatter.format("%02x", b);  
    }

    return sb.toString();
}catch (IOException e) {
    return "Couldn't serialize to hex string.";
} finally {
    formatter.close();
}
</code></pre>
 19331: <p>A shorter version could be:</p>

<pre><code>String hex = DatatypeConverter.printHexBinary(tx.unsafeBitcoinSerialize());
</code></pre>

<p>Where the hex converter used is standard at least since Java 7:</p>

<p><a href="http://docs.oracle.com/javase/7/docs/api/javax/xml/bind/DatatypeConverter.html" rel="nofollow">http://docs.oracle.com/javase/7/docs/api/javax/xml/bind/DatatypeConverter.html</a></p>
