Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ORIGINAL: http://pastebin.com/G4EHcQDz#
- //CREDITS TO Primetime43
- import java.io.IOException;
- import javax.swing.JOptionPane;
- import org.apache.commons.net.ftp.FTPClient;
- import org.apache.commons.net.ftp.FTPReply;
- public class MainConnect
- {
- private static void showServerReply(FTPClient ftpClient)
- {
- String[] replies = ftpClient.getReplyStrings();
- if (replies != null && replies.length > 0) {
- for (String aReply : replies) {
- JOptionPane.showMessageDialog(null, "SERVER: " + aReply);
- }
- }
- }
- public static void main(String[] args)
- {
- String server;
- String user;
- String pass;
- server = JOptionPane.showInputDialog("Enter Your PS3's IP Address");
- int port = 21;
- user = JOptionPane.showInputDialog("Enter Your PS3's Username");
- if (user.length() <= 1)
- {
- user = "anonymous";
- }
- pass = JOptionPane.showInputDialog("Enter Your PS3's Password");
- if(pass.length() <= 1)
- {
- pass= "**************";
- }
- FTPClient ftpClient = new FTPClient();
- try {
- ftpClient.connect(server, port);
- showServerReply(ftpClient);
- int replyCode = ftpClient.getReplyCode();
- if (!FTPReply.isPositiveCompletion(replyCode))
- {
- JOptionPane.showMessageDialog(null, "Operation failed. Server reply code: " + replyCode);
- return;
- }
- boolean success = ftpClient.login(user, pass);
- showServerReply(ftpClient);
- if (!success)
- {
- JOptionPane.showMessageDialog(null, "Could not login to the server");
- return;
- } else
- {
- JOptionPane.showMessageDialog(null, "LOGGED IN SERVER");
- }
- } catch (IOException ex)
- {
- JOptionPane.showMessageDialog(null, "Oops! Something wrong happened");
- ex.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement