Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- java.net.ConnectException: Connection timed out: connect
- at java.net.DualStackPlainSocketImpl.connect0(Native Method)
- at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
- at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
- at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
- at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
- at java.net.PlainSocketImpl.connect(Unknown Source)
- at java.net.SocksSocketImpl.connect(Unknown Source)
- at java.net.Socket.connect(Unknown Source)
- at org.apache.commons.net.SocketClient.connect(SocketClient.java:188)
- at org.apache.commons.net.SocketClient.connect(SocketClient.java:209)
- at Main.main(Main.java:135)
- String server2 = "ftp.aiub.unibe.ch";
- int port = 21;
- String user = "anonymous";
- String pass = "test";
- FTPClient ftpClient2 = new FTPClient();
- try {
- ftpClient2.connect(server2, port);
- ftpClient2.login(user, pass);
- ftpClient2.enterLocalPassiveMode();
- ftpClient2.setFileType(FTP.BINARY_FILE_TYPE);
- // CLK
- String remoteFile2 = "/CODE/" + y + "/COD" + gpsWeek + weekDayNumber + ".CLK.Z";
- File downloadFile2 = new File("D:/BERNESE/OUT/COD" + gpsWeek + weekDayNumber + ".CLK.Z");
- OutputStream outputStream2 = new BufferedOutputStream(new FileOutputStream(downloadFile2));
- boolean success2 = ftpClient2.retrieveFile(remoteFile2, outputStream2);
- outputStream2.close();
- if (success2) {
- System.out.println("File COD" + gpsWeek + weekDayNumber + ".CLK.Z has been downloaded successfully.");
- }
- // ION
- String remoteFile3 = "/CODE/" + y + "/COD" + gpsWeek + weekDayNumber + ".ION.Z";
- File downloadFile3 = new File("D:/BERNESE/ATM/COD" + gpsWeek + weekDayNumber + ".ION.Z");
- OutputStream outputStream3 = new BufferedOutputStream(new FileOutputStream(downloadFile3));
- boolean success3 = ftpClient2.retrieveFile(remoteFile3, outputStream3);
- outputStream3.close();
- if (success3) {
- System.out.println("File COD" + gpsWeek + weekDayNumber + ".ION.Z has been downloaded successfully.");
- }
- // EPH (PRE)
- String remoteFile4 = "/CODE/" + y + "/COD" + gpsWeek + weekDayNumber + ".EPH.Z";
- File downloadFile4 = new File("D:/BERNESE/ORB/COD" + gpsWeek + weekDayNumber + ".PRE.Z");
- OutputStream outputStream4 = new BufferedOutputStream(new FileOutputStream(downloadFile4));
- boolean success4 = ftpClient2.retrieveFile(remoteFile4, outputStream4);
- outputStream4.close();
- if (success4) {
- System.out.println("File COD" + gpsWeek + weekDayNumber + ".PRE.Z has been downloaded successfully.");
- }
- // ERP (IEP)
- String remoteFile5 = "/CODE/" + y + "/COD" + gpsWeek + weekDayNumber + ".ERP.Z";
- File downloadFile5 = new File("D:/BERNESE/ORB/COD" + gpsWeek + weekDayNumber + ".IEP.Z");
- OutputStream outputStream5 = new BufferedOutputStream(new FileOutputStream(downloadFile5));
- boolean success5 = ftpClient2.retrieveFile(remoteFile5, outputStream5);
- outputStream5.close();
- if (success5) {
- System.out.println("File COD" + gpsWeek + weekDayNumber + ".IEP.Z has been downloaded successfully.");
- }
- // DCB
- String remoteFile6 = "/CODE/" + y + "/P1C1" + shortYear + month + ".DCB.Z";
- File downloadFile6 = new File("D:/BERNESE/ORB/P1C1" + shortYear + month + ".DCB.Z");
- OutputStream outputStream6 = new BufferedOutputStream(new FileOutputStream(downloadFile6));
- boolean success6 = ftpClient2.retrieveFile(remoteFile6, outputStream6);
- outputStream6.close();
- if (success6) {
- System.out.println("File P1C1" + shortYear + month + ".DCB.Z has been downloaded successfully.");
- }
- } catch (IOException ex) {
- System.out.println("Error: " + ex.getMessage());
- ex.printStackTrace();
- } finally {
- try {
- if (ftpClient2.isConnected()) {
- ftpClient2.logout();
- ftpClient2.disconnect();
- }
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
Add Comment
Please, Sign In to add comment