Getting error in ftp from windows to unix box
Hi,
I have a written a java code to ftp a file from the windows box to unix box. It keeps giving me the following error : "java.io.FileNotFoundException: PORT 204,63,56,5,16,78: 550 Permission denied." I am able to ftp manually from windows to unix. Any pointers would be helpful. Thanks. Regards, Sangeeta |
Hi,
Can you paste your code here? (Please include the imports) |
Hi, Thanks for the prompt resonse. Here is my code :
import java.io.* ; import java.util.zip.*; import java.net.*; import sun.net.TelnetInputStream ; import sun.net.TelnetOutputStream ; import sun.net.ftp.FtpClient ; import weblogic.utils.encoders.BASE64Decoder; import weblogic.utils.encoders.BASE64Encoder; import org.apache.log4j.PropertyConfigurator; int len; byte[] buf = new byte[1024]; BufferedReader in = null; try { FtpClient ftp = null; String host = strServerIP;//Computername or IP Address ftp = new sun.net.ftp.FtpClient(host,21); TelnetInputStream telnetInputStream = null; //Computername or IP Address String username = strFTPUname; String password = strFTPPwd; /* Decrypt the password */ String strPass = decrypt(password); ftp.openServer(host,21); ftp.login(username, strPass); ftp.binary(); String hostPath=strLocationTO; String sFilePutPath=hostPath+sFilename; String Sourcepath= sFilePath+"abc.dat"; BufferedInputStream finStream = new BufferedInputStream( new FileInputStream(Sourcepath ) ); FileInputStream inputFile = new FileInputStream(Sourcepath); TelnetOutputStream telOut = ftp.put( sFilePutPath); int bytesAvailable = inputFile.available(); byte[] readByte = new byte[bytesAvailable]; int d = 0; while( ( d = finStream.read( readByte, 0, bytesAvailable )) != -1) { telOut.write( readByte, 0, bytesAvailable ); } finStream.close(); inputFile.close(); telOut.close(); |
Hi again,
It worked on my machine. My initial impression is that it might be something simple, like a missing trailing slash in the sFilePath? However, please note that you are using forbidden packages: Code:
import sun.net.TelnetInputStream ; I did a small search and found the following http://www.jibble.org/simpleftp/ which seems very straightforward to use. |
Thank you so much. I used apache package and it worked.
|
Glad to know you got it sorted out.
Good luck. |
All times are GMT -5. The time now is 09:08 PM. |