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.20 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 = "pass";
  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. URLConnection conn = url.openConnection();
  18. InputStream inputStream = conn.getInputStream();
  19. BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
  20.  
  21. String line = null;
  22. System.out.println("--- START ---");
  23. while ((line = reader.readLine()) != null) {
  24. System.out.println(line);
  25. }
  26. System.out.println("--- END ---");
  27.  
  28. inputStream.close();
  29. } catch (IOException ex) {
  30. ex.printStackTrace();
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement