MCPcopy Index your code
hub / github.com/Bit0r/java-util / readfile

Method readfile

src/main/java/util/AddTableField.java:214–245  ·  view source on GitHub ↗

读取某个文件夹下的所有文件

(String filepath)

Source from the content-addressed store, hash-verified

212 * 读取某个文件夹下的所有文件
213 */
214 public static List<String> readfile(String filepath) throws FileNotFoundException, IOException {
215 List<String> fileNames = new ArrayList<>();
216 File file = new File(filepath);
217 if (!file.isDirectory()) {
218 System.out.println("文件");
219 System.out.println("path=" + file.getPath());
220 System.out.println("absolutepath=" + file.getAbsolutePath());
221 System.out.println("name=" + file.getName());
222 } else if (file.isDirectory()) {
223 System.out.println("文件夹????");
224 String[] filelist = file.list();
225 for (int i = 0; i < filelist.length; i++) {
226 File readfile = new File(filepath + "\\" + filelist[i]);
227 if (!readfile.isDirectory()) {
228 String fileName = readfile.getPath();
229 System.out.println("path=" + fileName);
230 fileNames.add(fileName);
231// System.out.println("absolutepath="
232// + readfile.getAbsolutePath());
233// System.out.println("name=" + readfile.getName());
234
235 } else if (readfile.isDirectory()) {
236 //文件下面的文件夹 暂时不要
237// readfile(filepath + "\\" + filelist[i]);
238 }
239 }
240
241 }
242
243
244 return fileNames;
245 }
246
247 public static void main(String[] args) throws IOException {
248

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected