File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes FTP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "FTP" Watch "FTP" New topic


Richard West
Ranch Hand

Joined: Jan 07, 2005
Posts: 127
HI everyone,

Let's say when i connect to a ftp do i have to worry about something called type.

I mean for example let say when connect to an ftp as such

Do i have to worry about something called type as such

Does the first way i list above work or do i have to use the second way i listed with the type for the connection to be successful.

Which of the above two ways you have used and which do you find more effective or are both the same.

If i do not specify the type by using the first way is there a default?

If i have to use the one with the type what the different kinds of types are there?

Currently i only know two which are i = image and a = ascii

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West

[ EJFH: Disabled smilies ]
[ October 16, 2005: Message edited by: Ernest Friedman-Hill ]
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9059
I would guess that the two types would be ascii and binary, but I don't know whether or not you need to put that in the url. I don't remember every including that in the url.

If you try to ftp a binary file in ascii, you'll get garbage. On the other hand, binary mode seems to always work.

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
As Marilyn says, most FTP clients differentiate between two types of files: binary and ASCII. I don't think this type is included in the URL. Not only will a binary file treated as ASCII result in garbage. The file will be damaged. This is because each operating system has its own representation for an end of line sequence. I think the main reason that FTP clients worry about the "file type" is to deal with these differences and translate the "end of line sequence" from that used in the server's OS to that used in the client OS. This means that binary data will be modified if it is treated as ASCII text.

If you want/need this feature in the FTP client you are developing, then I think you will need to add your own logic to look at the data and convert EOLs as necessary. (As a disclaimer, the FTP protocol might have this built-in, but I'm unfamiliar with the specifics of the protocol to give a definite answer.)

[ October 16, 2005: Message edited by: Layne Lund ]

Java API Documentation
The Java Tutorial
Richard West
Ranch Hand

Joined: Jan 07, 2005
Posts: 127
Hi everyone,

Sorry to ask this but what does a html file classify under the ftp protocol. image or ascii?

Richard West
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
HTML files should be transferred using FTP in ascii mode.

However, if the HTML file contains Unicode characters, it should be transferred in binary (image) mode.
[ October 16, 2005: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
I agree. Here's the link:
subject: FTP
It's not a secret anymore!