ReadLineUtil删除临时文件
This commit is contained in:
parent
e52e27cebc
commit
52c8d04a76
|
@ -44,6 +44,7 @@ public class ReadLineUtil {
|
|||
throw new RuntimeException("ftp连接失败!");
|
||||
}
|
||||
InputStream iStream = null;
|
||||
File file = null;
|
||||
try {
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH) + 1);
|
||||
|
@ -63,7 +64,7 @@ public class ReadLineUtil {
|
|||
//读取ftp文件的输入流
|
||||
iStream=ftpClient.retrieveFileStream(ftpFile.getName());
|
||||
//声明一个临时文件
|
||||
File file = File.createTempFile("betaGamma", null);
|
||||
file = File.createTempFile("betaGamma", null);
|
||||
//将ftp文件的输入流复制给临时文件
|
||||
FileUtils.copyInputStreamToFile(iStream, file);
|
||||
List<String> allLines = FileUtils.readLines(file, encoding);
|
||||
|
@ -93,6 +94,9 @@ public class ReadLineUtil {
|
|||
if (Objects.nonNull(iStream)){
|
||||
iStream.close();
|
||||
}
|
||||
if (Objects.nonNull(file)) {
|
||||
file.delete();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user