How to Open a Text File with Notepad using JAVA in NetBeans

Опубликовано: 03 Декабрь 2024
на канале: raksrahul
35,908
72

How to Open a Text File with Notepad using JAVA in NetBeansIDE.

Here I used Runtime class and Process class to execute the command for opening notepad

1. Create a main class.

2. Enter code in main method {

Runtime rt=Runtime.getRuntime();

String file="path of your file";

Process p=load.exec("notepad "+file); // a space is required after notepad

3. Run the File.

4. Finish


To open Firefox, IExplorer or other browser with required page(url):

Process p=load.exec("path to browser executable file "+url); //url is the page to open


Follow us on :
Facebook :   / raksrahul-100219708647780  
Instagram :   / raksrahul_ig  

#Java #LearnJava #NetBeansIDE