У меня есть FTP-сервер, и я хочу показать все архивы, которые существуют на этом сервере, с использованием некоторого источника графики, например, свинга.
Я пытался получить имена файлов, но на самом деле он не показывает сами архивы, и не нашел никакого решения, кроме этого.
Также эта функция не работает в этом проекте, я не знаю, почему она не отвечает, но, используя другие проекты, она работает как положено.
package view;
import javax.swing.JFrame;
import java.awt.EventQueue;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import org.apache.commons.net.ftp.FTPClient;
import java.io.*;
import br.com.consiste.FtpConnector.*;
import java.awt.List;
import java.awt.Button;
public class ViewTela {
private JFrame frmServidorFtp;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ViewTela window = new ViewTela();
window.frmServidorFtp.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*
* @throws IOException
*/
public ViewTela() throws IOException {
initialize();
}
/**
* Initialize the contents of the frame.
*
* @throws IOException
*/
private void initialize() throws IOException {
frmServidorFtp = new JFrame();
frmServidorFtp.setTitle("Servidor FTP");
frmServidorFtp.setBounds(100, 100, 375, 445);
frmServidorFtp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmServidorFtp.getContentPane().setLayout(null);
List list = new List();
list.setBounds(10, 43, 339, 147);
frmServidorFtp.getContentPane().add(list);
Button button = new Button("New button");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
button.setBounds(35, 224, 84, 33);
frmServidorFtp.getContentPane().add(button);
FTPConnection connect = new FTPConnection();
FTPClient ftpClient = connect.createConnection();
FTPUtil util = new FTPUtil();
ArrayList<String> pastes = util.listPastes(ftpClient);
int size = util.listPastes(ftpClient).size();
System.out.println(size);
for (int index = 0; index < size; index++) {
pastes.get(index);
}
}
}
Мой файл POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>br.com.consiste</groupId>
<artifactId>FtpInterface</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>FtpInterface</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>br.com.consiste</groupId>
<artifactId>FtpConnector</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>