use of com.cas.sim.tis.util.FTPUtils in project TeachingInSimulation by ScOrPiOzzy.
the class LnkParser2 method getUtil.
private FTPUtils getUtil(String user, String password) {
FTPUtils util = new FTPUtils();
FTPClient client = new FTPClient();
util.setFtpClient(client);
util.setHost("192.168.1.122");
util.setPort(21);
util.setUsername(user);
util.setPassword(password);
return util;
}
use of com.cas.sim.tis.util.FTPUtils in project TeachingInSimulation by ScOrPiOzzy.
the class FileDownload method getUtil.
private FTPUtils getUtil(String user, String password) {
FTPUtils util = new FTPUtils();
FTPClient client = new FTPClient();
util.setFtpClient(client);
util.setHost("192.168.1.123");
util.setPort(21);
util.setUsername(user);
util.setPassword(password);
return util;
}
use of com.cas.sim.tis.util.FTPUtils in project TeachingInSimulation by ScOrPiOzzy.
the class FileDownload method testDownload.
@Test
public void testDownload() throws Exception {
FTPUtils ftpUtils = getUtil("admin", "admin");
List<String> pathArray = new ArrayList<>();
boolean f = ftpUtils.connect("/assets");
System.out.println(f);
ftpUtils.getPath("/assets", pathArray);
pathArray.forEach(System.out::println);
ftpUtils.download(pathArray, "./");
ftpUtils.disconnect();
}
use of com.cas.sim.tis.util.FTPUtils in project TeachingInSimulation by ScOrPiOzzy.
the class FileDownload method testUpload.
@Test
public void testUpload() throws Exception {
// 管理员可以上传文件
FTPUtils util = getUtil("admin", "admin");
boolean result = util.uploadFile("/assets/Model", new File("G:\\jfxrt.jar"), System.currentTimeMillis() + ".jar");
Assert.assertTrue(result);
// 匿名用户不允许上传
util = getUtil("anonymous", "");
result = util.uploadFile("/assets/Model", new File("G:\\jfxrt.jar"), System.currentTimeMillis() + ".jar");
Assert.assertFalse(result);
}
use of com.cas.sim.tis.util.FTPUtils in project TeachingInSimulation by ScOrPiOzzy.
the class FileDownload method testConcurrent.
@Test
public void testConcurrent() throws Exception {
FTPUtils util = getUtil("anonymous", "");
StopWatch w = new StopWatch();
w.start("开始下载");
InputStream stream = util.downloadFile("/assets/Model/", "11.j3o");
FileOutputStream out;
try {
File file;
out = new FileOutputStream(file = new File("model-file-" + 0));
Util.copyStream(stream, out);
out.close();
// 服务器中11.j3o文件大小是3,506,624
Assert.assertEquals(3506624, file.length());
w.stop();
System.out.println(w.getTotalTimeMillis());
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations