FTP File Transfer; file contents getting changed ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sriram

    #1

    FTP File Transfer; file contents getting changed ?

    Hi,
    I have wriiten a program to transfer a binary file.

    After transfer. The file contents in the destination machine is getting
    changed.

    Please Help.


    Please advice if i am doing any wrong. The number of bytes getting transfered
    is correct. only some of the bytes in the file (in the destination machine)
    are different.

    I dont know why is this happening.


    I have appened code segment.

    {

    Socket ds = new Socket(serverNa me, dataPort);

    if ( f.sendCommand(" type I" + f.eol, true) ) {
    System.out.prin tln("Main: bi");
    System.out.prin tln("bi results: " + f.cmdResponse );
    String filePath="C:\\s ri.bin";
    int line = 0;

    File f = new File(filePath);
    FileInputStream srcFile = new FileInputStream (f);
    BufferedInputSt ream bufFile = new BufferedInputSt ream(srcFile);
    DataInputStream inData = new DataInputStream (bufFile);

    OUT = new PrintWriter( ds.getOutputStr eam(), true );
    OUT.write("TYPE I"); /* setting transfer mode = BINARY */
    while ((line=inData.r ead()) != -1 ){
    OUT.write(line) ;
    }
    OUT.flush();
    OUT.close() ;

    }

    Regards,
    Ram
Working...