package com.alibaba.easyexcel.test.util;
import java.io.File;
import java.io.InputStream;
public class TestFileUtil {
public static InputStream getResourcesFileInputStream(String fileName) {
return Thread.currentThread().getContextClassLoader().getResourceAsStream("" + fileName);
}
public static String getPath() {
return TestFileUtil.class.getResource("/").getPath();
}
public static File createNewFile(String pathName) {
File file = new File(getPath() + pathName);
if (file.exists()) {
file.delete();
} else {
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
}
return file;
}
public static File readFile(String pathName) {
return new File(getPath() + pathName);
}
}
一个简单的文件读写创建工具类
猜你喜欢
转载自blog.csdn.net/qq_22744093/article/details/105823046
今日推荐
周排行