bitletorg / bitlet

A small Java bittorrent library, powering BitLet.org
155 stars 498 forks source link

save torrent file error #8

Open edeye opened 9 years ago

edeye commented 9 years ago

Metafile metafile = new Metafile(new BufferedInputStream(new FileInputStream(filename))); // filename1 is a new torrent file metafile.print(new BufferedOutputStream(new FileOutputStream(filename1, true))); //but filename1 can't be used

//first,edit Announce/Comment/FileName or something else in a torrent file,after that save a new torrent file,how to do that?

abahgat commented 9 years ago

Hi @edeye, what do you mean with the following?

//but filename1 can't be used

Could you share a snippet of code demonstrating what you're trying to do and the output you get?

edeye commented 9 years ago

very sorry that my english is not good... I want to edit the Comment in the torrent,@abahgat

    String filename = "C:\\Users\\k\\Desktop\\oldBtFile.torrent";
    Metafile metafile = new Metafile(new BufferedInputStream(
            new FileInputStream(filename)));
    String a = metafile.getComment();
    metafile.setComment(a + "my flag");

    String filename1 = "C:\\Users\\k\\Desktop\\newBtFile.torrent";
    metafile.print(new BufferedOutputStream(new FileOutputStream(filename1,
            true)));
    // when I use torrent Client open newBtFile.torrent, alert "Failure to obtain seed information"
    // how can I edit the Announce/Comment/Files in a torrent,then save a new one
abahgat commented 9 years ago

Thanks, I understand what you mean, I am adding tests to the library, so that we can reproduce that scenario.

abahgat commented 9 years ago

Hi @edeye, the test in 123684d is doing what you're trying to do here, but it seems like it's passing, can you take a look?

There's one thing that might explain what you're seeing, though: can you tell me what's the default encoding on the platform you're using?

Thanks

edeye commented 8 years ago

@abahgat I'am sorry that bother you again, = =! I want to edit a torrent file(such as some Sensitive words info,I need to change it), and save it to a new torrent file, then I can use the new torrent file which the Sensitive words has been changed

abahgat commented 8 years ago

It's hard to say what's going wrong without being able to see your code. Perhaps you could try uploading your code to a gist so that we can take a look?

Cheers!