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 import org.openqa.selenium.remote.internal.ApacheHttpClient;
33 public class TestFtp {
35 public static void main(String[] args) throws IOException {
36 // TODO Auto-generated method stub
37 AttFtpClient instance = AttFtpClient.getInstance();
39 String server = "135.177.130.113";
41 String user = "admin";
42 String pass = "admin";
43 AttFtpClient.getInstance().init(server, port, user, pass);
46 AttFtpClient.getInstance().retrieveListOfFile();
48 File retrieveLastModifiedFileFromFTP = instance.retrieveLastModifiedFileFromFTP();
49 String content = new String(Files.readAllBytes(Paths.get(retrieveLastModifiedFileFromFTP.getPath())), StandardCharsets.UTF_8);
50 // instance.deleteFilesFromFTPserver();
51 System.out.println(content);
52 readFile(retrieveLastModifiedFileFromFTP);
55 instance.terminateClient();
65 public static void readFile(File retrieveLastModifiedFileFromFTP) {
67 StringBuilder sb = new StringBuilder();
68 BufferedReader br = null;
70 br = new BufferedReader(new FileReader(retrieveLastModifiedFileFromFTP.getPath()));
72 while ((line = br.readLine()) != null) {
73 if (sb.length() > 0) {
78 } catch (IOException e) {
85 } catch (IOException ex) {
89 String contents = sb.toString();
90 System.out.println(contents);