String filePath = this.class.getClassLoader().getResource(pth).getFile();
File file = new File(filePath);
上面的方式在本地運(yùn)行通過,但是打成jar就無法讀取
改成一下方式
InputStream in = this.class.getClassLoader().getResourceAsStream(path);
byte[] bytes = toByteArray(in);
String filePath = this.class.getClassLoader().getResource(pth).getFile();
File file = new File(filePath);
上面的方式在本地運(yùn)行通過,但是打成jar就無法讀取
改成一下方式
InputStream in = this.class.getClassLoader().getResourceAsStream(path);
byte[] bytes = toByteArray(in);