my dog learned polymorphism*
The moose likes Beginning Java and the fly likes Open a specific text file ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Open a specific text file ?" Watch "Open a specific text file ?" New topic
Author

Open a specific text file ?

steve dowdall
Ranch Hand

Joined: May 23, 2001
Posts: 36
Hi,
My program generates a text output file. I'm opening notepad like this:
Runtime.getRuntime().exec("notepad");
It works fine. The question is how can I get a specific .txt file to open using this? Does anyone know the syntax to add the path so that I can point it to the directory (output) and file name (output.txt) where the program generates it to (c:\output\output.txt)?
Thanks,
steve
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Runtime.getRuntime().exec("notepad c:\output\output.txt");
[This message has been edited by Cindy Glass (edited October 11, 2001).]


"JavaRanch, where the deer and the Certified play" - David O'Meara
steve dowdall
Ranch Hand

Joined: May 23, 2001
Posts: 36
Cindy,
I had to do this (Windows OS I guess?): Runtime.getRuntime().exec("notepad c:\\Development\\xml-java\\output\\xml-output.txt");
Otherwise I get this error:
Invalid string literal, cannot contain character '\?'.
Runtime.getRuntime().exec("notepad c:\Development\xml java\output\xml-output.txt");
Slan,
Steve
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Yeah - sorry about that . Of course since you figured it out yourself it will stick with you FOREVER .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Open a specific text file ?