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

URL url = new URL("ftp://user:pass@ftp.fileplanet.com/polo.zip");

Do i have to worry about something called type as such

URL url = new URL("ftp://user:pass@ftp.fileplanet.com/polo.zip;type=i");

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

Depending on the server (whether it defaults to text mode, binary mode, or autodetects which is needed) the first may return a corrupted file.
You will get a connection in either case, but unless the data you are retrieving is text only not adding the 'i' flag may result in corruption as most ftp servers will transfer in text mode unless told otherwise.

Hi everyone,

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

Richard West

the html file itself is plain text. What protocol you use to retrieve it doesn't change that.
Of course any graphics and plugins (applets, flash, etc.) linked to for embedded display will be typically binary (though you can embed plain text as well).

Linked JS and CSS are text as well.

Hi everyone,

the html file itself is plain text

I could use binary to read a text file as well and from what i know that would not corrupt the file as long as i read all the bytes correctly back to my HD. Esentially its only a file. Like copying from place to another

I mean assuming there was a html file on the other side of the server and got its outputstream and i used the FIleOutputStream and read the html file back to HD. That would work as well would it not.

Correct me if i am wrong

Richard West
****************************************************

Of course. You can read a text file in binary mode without it getting corrupted, but not vice versa.

Not quite sure, but I think binary mode adds a layer of encoding to the transfer to ensure no data is lost (this is transparent).
FTP was originally created to transport only text data, and if I'm not mistaken uses 7 bits per byte (discarding one) just like SMTP.
Therefore binary data needs to be encoded from 8 down to 7 bits before being sent over the line.
Text data already fits in 7 bits (unless it's UTF-8 for exampl with the high bits in use, for example Chinese) and therefore needs no special treatment.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.