Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Failed uploading file to FTP with simple java program

800574Dec 23 2009 — edited Dec 23 2009
Hi,
I opened this new thread in order to be more specific.
When I'm trying to upload file with this ftp program I get an exception :
public void putFile(String localFile ,String m_sHostFile) { 
   String user = "myUser";
   String password = "mypassword";

   byte[] buffer = new byte[BUFFER_SIZE];
   try {
   m_client = new sun.net.ftp.FtpClient (host,21);
   m_client.login(user, password);
   m_client.binary(); 
   m_client.binary();


 File f = new File(localFile);
 int size = (int) f.length();
  FileInputStream in = new FileInputStream(localFile);
 OutputStream out = m_client.put(m_sHostFile);

int counter = 0;
while (true) {
int bytes = in.read(buffer);
if (bytes < 0)
  break;
out.write(buffer, 0, bytes);
counter+ = bytes;
System.out.println(counter);
}

out.close();
in.close();
} catch (Exception ex) {
ex.printStackTrace();
}
disconnect() ;
}
The exception is :
java.io.FileNotFoundException: PORT 10,40,5,198,8,168: 550 Permission denied.

at sun.net.ftp.FtpClient.readReply(FtpClient.java:251)
at sun.net.ftp.FtpClient.issueCommand(FtpClient.java:208)
at sun.net.ftp.FtpClient.openDataConnection(FtpClient.java:449)
at sun.net.ftp.FtpClient.put(FtpClient.java:609)
at util.FTPClient.putFile(FTPClient.java:62)
at util.FTPClient.main(FTPClient.java:33)


Important :
When I try to access this directory from client like FileZilla for example, I can access this directory and upoload file into it. It just doesnt work with this program.

Does anyone know what i'm missing here ?

Thanks

Edited by: George_.Smith on Dec 23, 2009 12:47 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 20 2010
Added on Dec 23 2009
4 comments
677 views