adsense


Monday, 26 October 2015

JAVA EXAMPLES FILES EXISTENCE PAGE 91

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



JAVA EXAMPLES FILES EXISTENCE


Java Examples - File Existence

Problem Description:
How to check a file exist or not?
Solution:
This example shows how to check a file�s existence by using file.exists() method of File class.
import java.io.File;

public class Main {
   public static void main(String[] args) {
      File file = new File("C:/java.txt");
      System.out.println(file.exists());
   }
}
Result:
The above code sample will produce the following result (if the file "java.txt" exists in 'C' drive).
true


No comments: