How to open an existing html file in java
hello everybody,
I have a problem with opening a html file through java.
I'm using java swing for my project. In that if i click a menu item the already existing html file must be opened. i'm not supposed to browse for the location where it has been store. For an end user we must provide the file as soon as the menu item is clicked.
Plz reply me
~regards
radha.srrini
Hi friend,
Here I attached the code to open the already existing notepad file. I think it will helpful to you....
import java.io.*;
import java.util.*;
class dynamic {
public static void main(String[] args){
try {
String input = "Hello World" ;
FileWriter fr = new FileWriter("output.txt");
if(input != null){
System.out.println(input);
fr.write(input);
}
fr.close();
Runtime r = Runtime.getRuntime();
Process p = null;
p = r.exec("notepad output.txt"); // This line is used open the purticular File. Inside the bracket you have to give command..
InputStream i = p.getInputStream();
System.out.println("i value:"+i);
}
catch (Exception e) {
System.out.println("Error executing notepad.");
}
}
}
Message was edited by:
ggopi