How to open any File in Java
In this video, I have shown how you can open any type of file using java.
Code is shown below.
package test;
import java.io.File;
public class open_file {
public static void main(String[] args) {
String path = "E:\\jinu.txt";
File file = new File(path);
try {
if (file.exists()) {
Process pro = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path);
pro.waitFor();
} else {
System.out.println("file does not exist");
}
} catch (Exception e) {
System.out.println(e);
}
}
}
0 Comments
Comments
Leave a Comment