Advertisement
BaSs_HaXoR

PS3 FTP Java - Primetime43

Oct 14th, 2014
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.09 KB | None | 0 0
  1. //ORIGINAL: http://pastebin.com/G4EHcQDz#
  2. //CREDITS TO Primetime43
  3.  
  4. import java.io.IOException;
  5. import javax.swing.JOptionPane;
  6. import org.apache.commons.net.ftp.FTPClient;
  7. import org.apache.commons.net.ftp.FTPReply;
  8. public class MainConnect
  9. {
  10.         private static void showServerReply(FTPClient ftpClient)
  11.         {
  12.         String[] replies = ftpClient.getReplyStrings();
  13.         if (replies != null && replies.length > 0) {
  14.             for (String aReply : replies) {
  15.                 JOptionPane.showMessageDialog(null, "SERVER: " + aReply);
  16.             }
  17.         }
  18.     }
  19.     public static void main(String[] args)
  20.     {
  21.         String server;
  22.         String user;
  23.         String pass;
  24.         server = JOptionPane.showInputDialog("Enter Your PS3's IP Address");
  25.         int port = 21;
  26.         user = JOptionPane.showInputDialog("Enter Your PS3's Username");
  27.         if (user.length() <= 1)
  28.         {
  29.                 user = "anonymous";
  30.         }
  31.         pass = JOptionPane.showInputDialog("Enter Your PS3's Password");
  32.         if(pass.length() <= 1)
  33.         {
  34.                 pass= "**************";
  35.         }
  36.         FTPClient ftpClient = new FTPClient();
  37.         try {
  38.             ftpClient.connect(server, port);
  39.             showServerReply(ftpClient);
  40.             int replyCode = ftpClient.getReplyCode();
  41.             if (!FTPReply.isPositiveCompletion(replyCode))
  42.             {
  43.                 JOptionPane.showMessageDialog(null, "Operation failed. Server reply code: " + replyCode);
  44.                 return;
  45.             }
  46.             boolean success = ftpClient.login(user, pass);
  47.             showServerReply(ftpClient);
  48.             if (!success)
  49.             {
  50.                 JOptionPane.showMessageDialog(null, "Could not login to the server");
  51.                 return;
  52.             } else
  53.             {
  54.                 JOptionPane.showMessageDialog(null, "LOGGED IN SERVER");
  55.             }
  56.         } catch (IOException ex)
  57.         {
  58.                 JOptionPane.showMessageDialog(null, "Oops! Something wrong happened");
  59.             ex.printStackTrace();
  60.         }
  61.     }  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement