判断网上邻居文件存在与否方法
2009-08-26 20:53
218 查看
由于java不支持通过//192.168.19.168/fz/OK/张立辰-国画/jpg/ZLC-鱼1-X.jpg这种路径
需要将路径映射为本地盘,则可
package test;
import java.io.File;
public class FileCheck {
/**
* @param args
*/
public static void main(String[] args) {
String filename="d://test.xml";
filename="o://test.xml";
filename="o://t";
filename="o://学习//学习.txt";
File f=new File(filename);
if (f.exists())
{
if (f.isFile())
{
System.out.println("is file exist ");
}
else
{
System.out.println("is folder exist ");
}
}
else
{
System.out.println("no");
}
System.out.println(checkFileExist(filename));
}
public static boolean checkFileExist(String filename)
{
//String filename="d://test.xml";
//filename="o://test.xml";
File f=new File(filename);
if (f.exists())
{
System.out.println("filename:"+filename+" exist");
return true;
}
else
{
System.out.println("filename:"+filename+" not exist");
return false;
}
}
}
需要将路径映射为本地盘,则可
package test;
import java.io.File;
public class FileCheck {
/**
* @param args
*/
public static void main(String[] args) {
String filename="d://test.xml";
filename="o://test.xml";
filename="o://t";
filename="o://学习//学习.txt";
File f=new File(filename);
if (f.exists())
{
if (f.isFile())
{
System.out.println("is file exist ");
}
else
{
System.out.println("is folder exist ");
}
}
else
{
System.out.println("no");
}
System.out.println(checkFileExist(filename));
}
public static boolean checkFileExist(String filename)
{
//String filename="d://test.xml";
//filename="o://test.xml";
File f=new File(filename);
if (f.exists())
{
System.out.println("filename:"+filename+" exist");
return true;
}
else
{
System.out.println("filename:"+filename+" not exist");
return false;
}
}
}
相关文章推荐
- Java编程实现判断网上邻居文件是否存在的方法
- 关于C++中如何判断文件,目录存在的若干方法
- Delphi怎么判断一个文件存在与否,文件还是文件夹?
- VC中判断目录,文件是否存在,创建目录,求目录或文件大小的方法
- C# 判断文件夹和文件是否存在的方法
- C语言中判断文件是否存在的方法详解
- linux 判断文件是否存在的access()方法与示例
- C语言判断文件夹或者文件是否存在的方法【转】
- VC++ 判断文件或文件夹是否存在的快捷方法 _access
- win8 metro开发中,判断文件是否存在的方法
- C语言判断文件夹或者文件是否存在的方法
- Qt - 正确判断文件、文件夹是否存在的方法
- java中直接判断ftp上文件夹下是否存在某文件的方法
- 【Qt】正确判断文件、文件夹是否存在的方法
- 【Qt】正确判断文件、文件夹是否存在的方法
- 2014-03-31工作日志:判断文件是否存在可以使用GetFileAttributes 方法。
- 在Web应用中,会用到大量的Ajax请求,在Ajax请求中存在的一个问题就是如何判断session超时,在网上找到的一个java中处理此问题方法:
- Python 判断文件是否存在的三种方法
- C语言判断文件夹或者文件是否存在的方法
- C#判断文件路径是否存在或者判断文件是否存在的方法