Guest User

Untitled

a guest
Jul 19th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. java.net.ConnectException: Connection timed out: connect
  2. at java.net.DualStackPlainSocketImpl.connect0(Native Method)
  3. at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
  4. at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
  5. at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
  6. at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
  7. at java.net.PlainSocketImpl.connect(Unknown Source)
  8. at java.net.SocksSocketImpl.connect(Unknown Source)
  9. at java.net.Socket.connect(Unknown Source)
  10. at org.apache.commons.net.SocketClient.connect(SocketClient.java:188)
  11. at org.apache.commons.net.SocketClient.connect(SocketClient.java:209)
  12. at Main.main(Main.java:135)
  13.  
  14. String server2 = "ftp.aiub.unibe.ch";
  15. int port = 21;
  16. String user = "anonymous";
  17. String pass = "test";
  18.  
  19. FTPClient ftpClient2 = new FTPClient();
  20.  
  21. try {
  22.  
  23. ftpClient2.connect(server2, port);
  24. ftpClient2.login(user, pass);
  25. ftpClient2.enterLocalPassiveMode();
  26. ftpClient2.setFileType(FTP.BINARY_FILE_TYPE);
  27.  
  28. // CLK
  29.  
  30. String remoteFile2 = "/CODE/" + y + "/COD" + gpsWeek + weekDayNumber + ".CLK.Z";
  31. File downloadFile2 = new File("D:/BERNESE/OUT/COD" + gpsWeek + weekDayNumber + ".CLK.Z");
  32. OutputStream outputStream2 = new BufferedOutputStream(new FileOutputStream(downloadFile2));
  33. boolean success2 = ftpClient2.retrieveFile(remoteFile2, outputStream2);
  34. outputStream2.close();
  35.  
  36. if (success2) {
  37. System.out.println("File COD" + gpsWeek + weekDayNumber + ".CLK.Z has been downloaded successfully.");
  38. }
  39.  
  40. // ION
  41.  
  42. String remoteFile3 = "/CODE/" + y + "/COD" + gpsWeek + weekDayNumber + ".ION.Z";
  43. File downloadFile3 = new File("D:/BERNESE/ATM/COD" + gpsWeek + weekDayNumber + ".ION.Z");
  44. OutputStream outputStream3 = new BufferedOutputStream(new FileOutputStream(downloadFile3));
  45. boolean success3 = ftpClient2.retrieveFile(remoteFile3, outputStream3);
  46. outputStream3.close();
  47.  
  48. if (success3) {
  49. System.out.println("File COD" + gpsWeek + weekDayNumber + ".ION.Z has been downloaded successfully.");
  50. }
  51.  
  52. // EPH (PRE)
  53.  
  54. String remoteFile4 = "/CODE/" + y + "/COD" + gpsWeek + weekDayNumber + ".EPH.Z";
  55. File downloadFile4 = new File("D:/BERNESE/ORB/COD" + gpsWeek + weekDayNumber + ".PRE.Z");
  56. OutputStream outputStream4 = new BufferedOutputStream(new FileOutputStream(downloadFile4));
  57. boolean success4 = ftpClient2.retrieveFile(remoteFile4, outputStream4);
  58. outputStream4.close();
  59.  
  60. if (success4) {
  61. System.out.println("File COD" + gpsWeek + weekDayNumber + ".PRE.Z has been downloaded successfully.");
  62. }
  63.  
  64. // ERP (IEP)
  65.  
  66. String remoteFile5 = "/CODE/" + y + "/COD" + gpsWeek + weekDayNumber + ".ERP.Z";
  67. File downloadFile5 = new File("D:/BERNESE/ORB/COD" + gpsWeek + weekDayNumber + ".IEP.Z");
  68. OutputStream outputStream5 = new BufferedOutputStream(new FileOutputStream(downloadFile5));
  69. boolean success5 = ftpClient2.retrieveFile(remoteFile5, outputStream5);
  70. outputStream5.close();
  71.  
  72. if (success5) {
  73. System.out.println("File COD" + gpsWeek + weekDayNumber + ".IEP.Z has been downloaded successfully.");
  74. }
  75.  
  76. // DCB
  77.  
  78. String remoteFile6 = "/CODE/" + y + "/P1C1" + shortYear + month + ".DCB.Z";
  79. File downloadFile6 = new File("D:/BERNESE/ORB/P1C1" + shortYear + month + ".DCB.Z");
  80. OutputStream outputStream6 = new BufferedOutputStream(new FileOutputStream(downloadFile6));
  81. boolean success6 = ftpClient2.retrieveFile(remoteFile6, outputStream6);
  82. outputStream6.close();
  83.  
  84. if (success6) {
  85. System.out.println("File P1C1" + shortYear + month + ".DCB.Z has been downloaded successfully.");
  86. }
  87.  
  88. } catch (IOException ex) {
  89. System.out.println("Error: " + ex.getMessage());
  90. ex.printStackTrace();
  91. } finally {
  92. try {
  93. if (ftpClient2.isConnected()) {
  94. ftpClient2.logout();
  95. ftpClient2.disconnect();
  96. }
  97. } catch (IOException ex) {
  98. ex.printStackTrace();
  99. }
  100. }
Add Comment
Please, Sign In to add comment