Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tgactool;
- import java.io.*;
- import java.net.*;
- public class FTPclientConn {
- public final String host;
- public final String user;
- protected final String password;
- protected URLConnection urlc;
- public FTPclientConn(String _host, String _user, String _password) {
- host= _host; user= _user; password= _password;
- urlc = null;
- }
- protected URL makeURL(String targetfile) throws MalformedURLException {
- if (user== null)
- return new URL("ftp://"+ host+ "/"+ targetfile+ ";type=i");
- else
- return new URL("ftp://"+ user+ ":"+ password+ "@"+ host+ "/"+ targetfile+ ";type=i");
- }
- protected InputStream openDownloadStream(String targetfile) throws Exception {
- URL url= makeURL(targetfile);
- urlc = url.openConnection();
- InputStream is = urlc.getInputStream();
- return is;
- }
- protected OutputStream openUploadStream(String targetfile) throws Exception {
- URL url= makeURL(targetfile);
- urlc = url.openConnection();
- OutputStream os = urlc.getOutputStream();
- return os;
- }
- protected void close() {
- urlc= null;
- }
- }
Add Comment
Please, Sign In to add comment