• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

ANT FTP download new line problem.

 
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
while downloading some class files and jsp files from remote server i am getting some special character at the end of each line and i can see it this in text editor for jsp files and java decompiler is unable to open my class files. what to do to remove those unwanted characters.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See if fixcrlf task helps.
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you use the ftp task to get the files? Did you remember to set the binary mode attribute?

Also what OS are you transferring files from and to. If you do not have binary mode set, when files are transferred from Linux to Windows, a CR char is added before every LF char. And in the other direction, every CR-LF combo is changed to only LF.
 
hasan khan
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FixCRLF helped me to some extend for JSP files, but didnt worked for .class files.
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to FTP class files with the binary option set. Using FixCrLf can further corrupt binary files.
[ July 17, 2008: Message edited by: Peter Johnson ]
 
hasan khan
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so please suggest any solution for downloading any binary file from UNIX to windows using ANT FTP.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the ant task you are using to download the files from FTP. Based on the FTP task documentation, the binary mode is set to "yes" by default.
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finally! I now know the direction you are transferring files. And with FTP the direction of transfer is critical.

Your original post has me confused. You claim that both Java source files (text) and class files (binary) were corrupted during the FTP. That is not possible from a single FTP task. Let me explain.

1) If you ftp as binary, then text files keep the CR-LF line ending characters. And in an editor on Linux you will see funny characters at the end of each line. But binary files are transferred as-is, meaning the class files could not have been corrupted.

2) If you ftp as text, the the Java source files will transfer correctly, with CR-LF chars being changed to LF. No funny characters at end-of-line in the editor. But that same CR-LF to LF conversion can corrupt binary files, meaning your class files are now corrupt.

Therefore, either the source files of the class files get corrupted in a single ftp transfer. But not both.

FixCrLf can further corrupt binary files. Consider a binary file on Windows with some LF chars and some CR-LF combinations. After a text mode ftp to Linux, all of the CR-LF combos will be turned to LF. Running FixCrLf then takes all LF chars and converts them to CR-LF, leaving no free-standing LF chars (as there were in the original binary). So the binary is still screwed up. In short, after a text-mode FTP, binary files are hopelessly corrupt and cannot be fixed. The only solution is to re-transfer the file in binary mode.

(Sorry, I was a teacher in a former life and occasionally that teacher repossesses my body...)
 
hasan khan
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have modified org.apache.commons.net.ftp.FTPClient.setFileType(int fileType) by adding line this in the beginning.


and it is working fine for me.
 
eat bricks! HA! And here's another one! And a tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic