Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
8.2k views
in Java FTP by
Hey Guys,

so.. the edtftp Package is great, but i have one problem.

The put with byte[] make no new line in the target file. The byte code is build up with "\n".

I look now at the source of putData method and see there's a Property for Line.Separator ?!

Do I need the Property File? Where is it to store?! Whats the Content?

Or what can I do?

Thanks 4 help !

13 Answers

0 votes
by (162k points)
Line.separator is a Java property.

Try using the method with ASCII mode set.

Hey Guys,

so.. the edtftp Package is great, but i have one problem.

The put with byte[] make no new line in the target file. The byte code is build up with "\n".

I look now at the source of putData method and see there's a Property for Line.Separator ?!

Do I need the Property File? Where is it to store?! Whats the Content?

Or what can I do?

Thanks 4 help !
0 votes
by
Line.separator is a Java property.

Try using the method with ASCII mode set.

Hey Guys,

so.. the edtftp Package is great, but i have one problem.

The put with byte[] make no new line in the target file. The byte code is build up with "\n".

I look now at the source of putData method and see there's a Property for Line.Separator ?!

Do I need the Property File? Where is it to store?! Whats the Content?

Or what can I do?

Thanks 4 help !



Oh I see..

Thanks for your answer, but my FTP Connection is in ASCII Mode.
Look at this:

        try {
            // set up client
            log.info("Connecting");

            ftp = new FTPClient(host);
            listener = new FTPMessageCollector();
            ftp.setMessageListener(listener);

             // login
            log.info("Logging in");
            ftp.login(user, password);

            // set up passive ASCII transfers
            log.debug("Setting up passive, ASCII transfers");
            ftp.setConnectMode(FTPConnectMode.PASV);
            ftp.setType(FTPTransferType.ASCII);

        } catch (Exception e) {
            e.printStackTrace();
        }        


When I convert the Byte Array back to String and put it to the console, then is the output correct !
:(
0 votes
by (162k points)
I'm not too sure what the problem here is.

If you are putting a file to a Unix machine from Windows in ASCII mode, the CRLF at the end of a line will be replaced by LF. If putting to another Windows machine, CRLF -> CRLF.


When I convert the Byte Array back to String and put it to the console, then is the output correct !
:(
0 votes
by
I'm not too sure what the problem here is.

If you are putting a file to a Unix machine from Windows in ASCII mode, the CRLF at the end of a line will be replaced by LF. If putting to another Windows machine, CRLF -> CRLF.


When I convert the Byte Array back to String and put it to the console, then is the output correct !
:(


My problem is, when i put data from file to a Unix Machine - the data at target is correct with new lines. But when i send data as a byte array then no new lines are produced in target file. My Line Separator is a "\n".
0 votes
by (162k points)
What version are you using?

My problem is, when i put data from file to a Unix Machine - the data at target is correct with new lines. But when i send data as a byte array then no new lines are produced in target file. My Line Separator is a "\n".
0 votes
by
What version are you using?

My problem is, when i put data from file to a Unix Machine - the data at target is correct with new lines. But when i send data as a byte array then no new lines are produced in target file. My Line Separator is a "\n".


Version 1.5.1
0 votes
by (162k points)
I'm sorry, I'm still not too clear on the problem. Let me try to summarise what I think you are saying.

When you put a text file from Windows to Unix using one of the put methods to file, everything is ok (\n line separators). When you send the same data as a byte array, there are no \n separators?

My problem is, when i put data from file to a Unix Machine - the data at target is correct with new lines. But when i send data as a byte array then no new lines are produced in target file. My Line Separator is a "\n".
0 votes
by
I'm sorry, I'm still not too clear on the problem. Let me try to summarise what I think you are saying.

When you put a text file from Windows to Unix using one of the put methods to file, everything is ok (\n line separators). When you send the same data as a byte array, there are no \n separators?



Well, the Line Separator is in byte code but not at target. You know what I mean? The Data at target is write in one Line !

A example:
I have a File with 10 Lines. When I use the File-Put Method and put the Data to a Unix File then are 10 Lines at target, too.

Now i have 10 Lines in byte code, where the Lines are separated by a "\n".
I use the Byte-Put Method and no 10 Lines are created at target file- only one Line with all Data !

Should I use a other Line Separator as "\n" ?!

I'm sorry for my bad English :)
0 votes
by
You should use the Line Separator "\r\n" :oops: :D :roll:

Thanks for help. It's solved.
0 votes
by (162k points)
How is it solved?

The thing that I find confusing is that it is the same code that does the put, for both byte arrays and files. So there shouldn't be any difference.

You should use the Line Separator "\r\n" :oops: :D :roll:

Thanks for help. It's solved.

Categories

...