Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to copy file to ftp  RSS feed

 
Irakli Bliadze
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have such code
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
HttpSession httpSession = request.getSession(false);
String resourcePath = request.getSession().getServletContext().getRealPath("resources");
File src = new File("D:/demo.pdf");
File dst = new File(resourcePath+"\\demo.pdf");
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);

// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
and if server is on local computer its copies demo.pdf from "D" disc to web/resources folder
but how to copy file from D to ftp server s web/resources?
anybody can help me?
 
Tim Moores
Saloon Keeper
Posts: 3881
91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Apache Commons Net library contains a decent FTP client.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!