求代码例子---在线等 String fullpath = ...;if ( !(new File(fillpath)).exists() ) { // ... save the file} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 File file = new File("file");if(file.exits()){//存}else{//步存} void saveFile(String dir, String fileName) throws IOException{ File directory = new File(dir); File[] fileList = null; String inputFile = fileName; boolean existFlag = false; if (directory.exists() && directory.isDirectory()) { fileList = directory.listFiles(); for(int i = 0; i < fileList.length; i++) { if (fileList[i].isFile()) { if(fileList[i].getName().equals(inputFile)) System.out.println("File Already Exist"); existFlag = true; } } } } else { System.out.println(directory.getName() + " is not a valid directory"); } if (!existFlag) { file://save a file, you need to do it }} 求解:又一个String问题啊! 高手进,关于JWindow hsql无法将插入数据写入脚本文件中 求救:表格中某列查询出的内容太长的处理? 小问题半天结帖 第一次用JAVA请高手指点 graphics对象为空? MVC模式下开发的DataBean问题 太奇怪了,float类型变量居然赋值不了!!!! 我想了解一些关于Java怎样与Asp或Asp.net结合方面在未来发展方向的问题? 关于jfreechart问题 大家都来看看,参与有分。
if(file.exits()){
//存
}
else{
//步存
}
{
File directory = new File(dir);
File[] fileList = null;
String inputFile = fileName;
boolean existFlag = false; if (directory.exists() && directory.isDirectory())
{
fileList = directory.listFiles();
for(int i = 0; i < fileList.length; i++)
{
if (fileList[i].isFile())
{
if(fileList[i].getName().equals(inputFile))
System.out.println("File Already Exist");
existFlag = true;
}
}
}
}
else
{
System.out.println(directory.getName() + " is not a valid directory");
} if (!existFlag)
{
file://save a file, you need to do it
}
}