Author
File transfering from client machine to Server through FTP.
Gopal krushna Das
Greenhorn
Joined: Jul 03, 2008
Posts: 9
posted Jul 31, 2008 04:18:00
0
Hi, I want to make the password hardcoode in this program. Please help me.. //Gopal Das import com.jscape.inet.ftp.*; import java.io.*; import java.util.Enumeration ; public class FtpMuploadExample extends FtpAdapter { private String hostname; private String username; private String password; // perform multiple file upload public void doUpload(String hostname, String username, String password) throws FtpException { Ftp ftp = new Ftp(hostname,username,password); //capture Ftp related events ftp.addFtpListener(this); ftp.connect(); ftp.setBinary(); ftp.mupload(".*\\MUT*.*"); ftp.disconnect(); } // captures upload event public void upload(FtpUploadEvent evt) { System.out.println("Uploaded file: " + evt.getFilename()); } // captures connect event public void connected(FtpConnectedEvent evt) { System.out.println("Connected to server: " + evt.getHostname()); } // captures disconnect event public void disconnected(FtpDisconnectedEvent evt) { System.out.println("Disconnected from server: " + evt.getHostname()); } public static void main(String[] args) { String hostname ; String username; String password; try { BufferedReader reader = new BufferedReader (new InputStreamReader (System.in)); System.out.print("Enter Ftp hostname : "); hostname = reader.readLine().trim(); System.out.print("Enter username : "); username = reader.readLine().trim(); System.out.print("Enter password : "); password = reader.readLine().trim(); System.out.println("Using upload filter .*\\MUT*.*"); FtpMuploadExample example = new FtpMuploadExample(); example.doUpload(hostname,username,password); } catch(Exception e) { e.printStackTrace(); } } }
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
posted Jul 31, 2008 04:31:00
0
Please don't post the same question in multiple forums.
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Norm Radder
Ranch Hand
Joined: Aug 10, 2005
Posts: 681
posted Jul 31, 2008 05:45:00
0
Use: private String password = "the password"; // hardcoded password
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
posted Jul 31, 2008 05:55:00
0
Norm - despite what it says in the OP's post, that isn't actually what he was asking. See this post for what was actually needed. Gopal - this is a perfect example of why you shouldn't post the same question multiple times. [ July 31, 2008: Message edited by: Joanne Neal ]
Joanne
Norm Radder
Ranch Hand
Joined: Aug 10, 2005
Posts: 681
posted Jul 31, 2008 07:19:00
0
Its a real art figuring out what some OPs are asking. Throwing a stupid response at them sometimes gets them to rephrase the question. Thanks
subject: File transfering from client machine to Server through FTP.