0

I know how to write messages and save it as a .txt file (using Input/Output streams). What I want to do now is to be able to click a button and have notepad open the .txt file. How can I do this?

4
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by glenak
0

You can use the Process class to execute OS commands like Notepad.
For code examples use Search here or Google.

0

Another option is the Desktop.open() method. You have more control with the Process the NormR1 mentioned, but it is OS-specific. The choice depends on your particular needs.

0

Hi Norm, this is what I was able to find:

Process p = Runtime.getRuntime().exec("notepad.exe ctpublish/numnum.txt");

however this seems to run a thread that won't exit until I close the notepad file, numnum.txt. Is there a way to just have the Process p run and end without me having to shut down notepad?

0

What does the API doc say?
I don't know if you can end the process if Notepad is still executing?

0

This is code i use actually to open the browser in windows, and it seems to open notepad with a txt file on my computer.

try {
  Runtime rt = Runtime.getRuntime();

				 String[] cmd = new String[4];
	              cmd[0] = "cmd.exe";
	              cmd[1] = "/C";
	              cmd[2] = "start";
	              cmd[3] = "manifest.txt";

	              rt.exec(cmd);

}
catch(Exception e){}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.