2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.execute.setup;
23 import java.io.BufferedReader;
25 import java.io.FileReader;
26 import java.io.IOException;
27 import java.nio.charset.StandardCharsets;
28 import java.nio.file.Files;
29 import java.nio.file.Paths;
31 public class TestFtp {
33 public static void main(String[] args) throws IOException {
34 AttFtpClient instance = AttFtpClient.getInstance();
36 String server = "localhost";
38 String user = "admin";
39 String pass = "admin";
40 AttFtpClient.getInstance().init(server, port, user, pass);
43 AttFtpClient.getInstance().retrieveListOfFile();
45 File retrieveLastModifiedFileFromFTP = instance.retrieveLastModifiedFileFromFTP();
46 String content = new String(Files.readAllBytes(Paths.get(retrieveLastModifiedFileFromFTP.getPath())), StandardCharsets.UTF_8);
47 // instance.deleteFilesFromFTPserver();
48 System.out.println(content);
49 readFile(retrieveLastModifiedFileFromFTP);
52 instance.terminateClient();
62 public static void readFile(File retrieveLastModifiedFileFromFTP) {
64 StringBuilder sb = new StringBuilder();
65 BufferedReader br = null;
66 FileReader fileReader = null;
68 fileReader = new FileReader(retrieveLastModifiedFileFromFTP.getPath());
69 br = new BufferedReader(fileReader);
71 while ((line = br.readLine()) != null) {
72 if (sb.length() > 0) {
77 } catch (IOException e) {
78 System.out.println(e);
84 if(fileReader != null) {
87 } catch (IOException ex) {
88 System.out.println(ex);
91 String contents = sb.toString();
92 System.out.println(contents);