Tuesday, 3 December 2013

Unknown

How To Open Notepad Using Java Code

import java.util.*;
import java.io.*;
class Notepad {
public static void main(String[] args) {
Runtime rs = Runtime.getRuntime();
try {
rs.exec("notepad");
}
catch (IOException e) {
System.out.println(e);
}
}
}
Explanation:
getRunTime method is used to get reference of current RunTime object, exec method can be used to execute commands. You can also specify a file while opening notepad such as exec("notepad programming.txt") where xist in current working directory then a dialog box will be displaye'programming.txt' is the file you wish to open, if the file doesn't ed to create file. You can launch other applications using exec method, for is present in a directory which is not set in environment varia example exec("calc") will launch calculator application. If an application ble PATH then you can specify complete path of application. If you are still using Notepad for Java development it is recommended to switch
to some advanced text editor like Notepad++ or use a development IDE.

Unknown

About Blog No Baap -

Since 2016 BlogNoBaap has been bringing you the very best in all types of web resources. Posted daily, and delivered straight to your inbox each morning.

Subscribe to this Blog via Email :