Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. public static void main(String[] args) {
  2. String ftpUrl = "ftp:////%s:%s@%s//%s;type=a";
  3. String host = "37.187.139.123";
  4. String user = "joe.shuff@btinternet.com.2995";
  5. String pass = "SLs28vy03n";
  6. String dirPath = "eula.txt";
  7.  
  8. ftpUrl = String.format(ftpUrl, user, pass, host, dirPath);
  9. System.out.println("URL: " + ftpUrl);
  10.  
  11. StringSelection selection = new StringSelection(ftpUrl);
  12. Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
  13. clipboard.setContents(selection, selection);
  14.  
  15. try {
  16. URL url = new URL(ftpUrl);
  17.  
  18. System.out.println(url.getHost());
  19. System.out.println(String.valueOf(url.getPort()));
  20.  
  21. URLConnection conn = url.openConnection();
  22. InputStream inputStream = conn.getInputStream();
  23. BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
  24.  
  25. String line = null;
  26. System.out.println("--- START ---");
  27. while ((line = reader.readLine()) != null) {
  28. System.out.println(line);
  29. }
  30. System.out.println("--- END ---");
  31.  
  32. inputStream.close();
  33. } catch (IOException ex) {
  34. ex.printStackTrace();
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement