Properties properties = System.getProperties();
String s = new String(properties.getProperty("user.dir"));File system=new File(s+"\\"+"system");
if(!system.isDirectory()){
system.mkdir();}File domainInfo=new File(s+"\\system\\domainInfo.ini");
try{ domainInfo.createNewFile();
}catch(IOException exp){}
这个是正确的呀,看是否你别的地方错误了!
String s = new String(properties.getProperty("user.dir"));File system=new File(s+"\\"+"system");
if(!system.isDirectory()){
system.mkdir();}File domainInfo=new File(s+"\\system\\domainInfo.ini");
try{ domainInfo.createNewFile();
}catch(IOException exp){}
这个是正确的呀,看是否你别的地方错误了!
应该是你这句话离地问题,line.separator里面存的什么东西!在什么目录下!
看看文件创建在哪儿!
如果还不队,
//改成试试
domainInfo=new File(system,"domainInfo.ini");// 要不,
\\ 全部改成 / 试试!
从来没有遇到过这样的问题!!!
这里的domainInfo.getName()很有可能取到的只是最终的文件名,而不带路径,所以生成的文件总是在默认目录下.换成这个试试domainInfo.getAbsolutePath()
FileWriter fw=new FileWriter(domainInfo.toString(),true);
也可以的!
if(devices.exists()){
FileReader fr=new FileReader(devices);
BufferedReader br=new BufferedReader(fr);
while((record=br.readLine())!=null){
StringTokenizer token=new StringTokenizer(record,"+");
if(token!=null){
while(token.hasMoreElements()){
//aaaaaaaaaaaaaaaaaa;
}
}
}
}else{
devices.createNewFile();
}
}catch(IOException exp){
JOptionPane.showMessageDialog(null,exp.toString());
}
这样就好了!!非常感谢大家!!!