public void ArrayListToFile() {
FileWriter out=null;
BufferedWriter bw=null;
try {
file=new File(this.getClass().getResource("/data/classmatesdata.txt").toURI());
//这里file的路径有问题,应该如何去写啊
} catch (URISyntaxException e1) {
e1.printStackTrace();
}
try {
out=new FileWriter(file);
bw=new BufferedWriter(out);
Iterator<Classmate> it=classmateList.iterator();
while(it.hasNext()) {
Classmate classmate=it.next();
...
...
}
bw.flush();
out.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
FileWriter out=null;
BufferedWriter bw=null;
try {
file=new File(this.getClass().getResource("/data/classmatesdata.txt").toURI());
//这里file的路径有问题,应该如何去写啊
} catch (URISyntaxException e1) {
e1.printStackTrace();
}
try {
out=new FileWriter(file);
bw=new BufferedWriter(out);
Iterator<Classmate> it=classmateList.iterator();
while(it.hasNext()) {
Classmate classmate=it.next();
...
...
}
bw.flush();
out.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
可变的不要放到jar文件里
字体/声音/文本 使用 getResourceAsStream 这里 lz 你读取 text 文件 应该使用 getResourceAsStream