Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

[Question] Generate a format for FTP server

Edwin_wingEdwin_wing Posts: 15Member
I am writing a ftp server and I have somethings to ask.
When I use my toy java ftp client connect to well know FTP server such as winftp. I can receive the following format when I send "LIST" to the server:

[code]-rw-r--r-- 1 1002 1002 21861 Apr 26 16:17 123.jpg
drwxr-xr-x 2 1002 1002 4096 Apr 14 06:07 abc
-rw-r--r-- 1 1002 1002 6 Apr 16 06:29 good.java
-rw-r--r-- 1 1002 1002 0 Apr 20 05:35 bad.java[/code]

Now, when my toy ftp server receive a "LIST" command, I need to send somethings like the above format.
I tried other format such as
[code]- 123.jpg
d abc[/code]
But it doesn't work because this format cannot be read by the ftp client.

So, I tried to foo the ftp client. I just hard code the above strings and send to the client. The client can be fooled by me =].

My question is "In java, is there any function or class can help me to make such kind of format?". Or can anyone tell me what format will be recognized by the client? This is because such format is difficult to build such as the first column (-rw-r--r--) and I don't know what every column means.

Comments

  • zibadianzibadian Posts: 6,349Member
    : I am writing a ftp server and I have somethings to ask.
    : When I use my toy java ftp client connect to well know FTP server
    : such as winftp. I can receive the following format when I send
    : "LIST" to the server:
    :
    : [code]: -rw-r--r-- 1 1002 1002 21861 Apr 26 16:17 123.jpg
    : drwxr-xr-x 2 1002 1002 4096 Apr 14 06:07 abc
    : -rw-r--r-- 1 1002 1002 6 Apr 16 06:29 good.java
    : -rw-r--r-- 1 1002 1002 0 Apr 20 05:35 bad.java[/code]:
    :
    : Now, when my toy ftp server receive a "LIST" command, I need to send
    : somethings like the above format.
    : I tried other format such as
    : [code]: - 123.jpg
    : d abc[/code]:
    : But it doesn't work because this format cannot be read by the ftp
    : client.
    :
    : So, I tried to foo the ftp client. I just hard code the above
    : strings and send to the client. The client can be fooled by me =].
    :
    : My question is "In java, is there any function or class can help me
    : to make such kind of format?". Or can anyone tell me what format
    : will be recognized by the client? This is because such format is
    : difficult to build such as the first column (-rw-r--r--) and I don't
    : know what every column means.
    :
    There's probably a 3rd party code for this, just google for it. You can create a formatted string using either the String.format() method or the Formatter class.
    The first column includes the file flags (like read/write/execute/delete), but I don't know which order. I don't know what the 1002 and 1/2 mean, but just before the date/time is the file size, in either bytes or kB.
    The meaning of each column should be documented in the FTP specification.
Sign In or Register to comment.