import lombok.Data;
import java.io.Serializable;
/**
* @Author zyh
* @Date 2020/7/21 14:33
*/
@Data
public class FileDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private Long languageId;
}
/**
* 读取文件夹内所有文件
* @param path 文件夹路径
* @return
*/
private static List<FileDTO> readAllFile(String path,List<FileDTO> fileDTOList){
File file = new File(path);
if (!file.exists()) {
return fileDTOList;
}
if (!file.isDirectory()) {
return fileDTOList;
}
String[] tempList = file.list();
File temp = null;
for (int i = 0; i < tempList.length; i++) {
if (path.endsWith(File.separator)) {
temp = new File(path + tempList[i]);
} else {
temp = new File(path + File.separator + tempList[i]);
}
if (temp.isFile()) {
String name = temp.getName();
FileDTO fileDTO=new FileDTO();
fileDTO.setName(name);
fileDTOList.add(fileDTO);
}
if (temp.isDirectory()) {
readAllFile(temp.getAbsolutePath(),fileDTOList);
}
}
return fileDTOList;
}