Java programming implements a method to determine whether a neighbor file exists on the web

  • 2020-04-01 04:18:37
  • OfStack

This article illustrates a method for Java programming implementations to determine the existence of neighborhood files on the web. Share with you for your reference, as follows:

Because Java does not support through / / 192.168.19.168 / fz/OK/zhang licheng - Chinese painting/JPG/zlc-fish 1-x.pg this path

Need to map the path to the site, can


package test;
import java.io.File;
public class FileCheck {
 
 public static void main(String[] args) {
 String filename="d://test.xml";
 filename="o://test.xml";
 filename="o://t";
 filename="o:// learning // learning .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;
 }
 }
}

I hope this article has been helpful to you in Java programming.


Related articles: