I'm using the following code snippet to download and save a file from an address using Java...
URL website = new URL("http://www.website.com/example.torrent"); ReadableByteChannel rbc = Channels.newChannel(website.openStream()); FileOutputStream fos = new FileOutputStream("example.torrent"); fos.getChannel().transferFrom(rbc, 0, 1 << 24);
However, a problem occurs when I try to download a file with the extension ".torrent". After downloading a torrent file, when I click on that file, Bittorrent gives me the following error...
"example.torrent" is not valid bencoding.
I think, in a way, torrent file become changed or broken during download. Is there a solution for it, or is there something wrong in the code snippet above?
Thank you in advance.