FTP File Transfer; file contents getting changed ?

0 views
Skip to first unread message

Sriram

unread,
Sep 4, 2004, 3:32:29 AM9/4/04
to
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(serverName, dataPort);

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

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

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

}

Regards,
Ram

Reply all
Reply to author
Forward
0 new messages