Below I have a snipit of code which is supposed to place the file "test_transfer.txt" on the specified host. However, I am getting the following error and I don't know why. I can transfer the file, without problems, through a regular FTP program.
If anyone can point out what I am not seeing please do so. Also, I am required to use the FtpClient Class.
I'm not sure why this would cause the error you are seeing, butproduces a String that contains "C", ":", tab character, "e", "s" and so on. That's because "\t" is the Java escape for the tab character. What you want is to escape the backslash so it comes out as itself:
Craig Dumolien
Greenhorn
Joined: Nov 07, 2005
Posts: 20
posted
0
The problem I was having was that the FtpClient.put method returns an OutputStream, which I was doing nothing with.
Below is the code where I'm actually working with that OutputStream. However, now the file is getting created on the server, but the text inside the file is not getting transfered.
Any ideas? Thanks.
osTestTransfer = client.put("test_transfer.txt"); bosTestTransfer = new BufferedOutputStream(osTestTransfer);
if (testTransferFile.exists()) { isTestTransfer = new FileInputStream(testTransferFile); bisTestTransfer = new BufferedInputStream(isTestTransfer);
int bytesRead1 = 0; while ( (bytesRead1 = bisTestTransfer.read(buffer)) > 0 ) { bosTestTransfer.write(buffer,0,bytesRead1); } }
Craig Dumolien
Greenhorn
Joined: Nov 07, 2005
Posts: 20
posted
0
I figured that one out. I needed to do a bosTestTransfer.flush(); when the while statement finished.
The reason nothing showed up is that I was using an file with less than 4096 bytes.
Thanks for the help.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.