I should open a .txt file on my java application, so i've searched a way to do this but what i've found is only java calls to operating system, writing console commands. There is a way to open a .txt file independently of operating system of the user? Note that I want to open an application that reads .txt, not only its content! I'm wondering if there is a way to call default application for reading .txt, without write for example "notepad myTxt.txt" on console from java :)
Asked
Active
Viewed 207 times
2
-
1possible duplicate of [Best way to read a text file](http://stackoverflow.com/questions/4716503/best-way-to-read-a-text-file) – Filip Roséen - refp Jul 14 '12 at 16:07
-
1That's very different than how your question reads. I recommend that you update "edit" your question. – Chimera Jul 14 '12 at 16:12
2 Answers
2
You can use Desktop.open()
From the Javadocs:
Launches the associated application to open the file.
http://docs.oracle.com/javase/6/docs/api/java/awt/Desktop.html#open(java.io.File)
An alternative (because you mentioned "editing") might also be Desktop.edit()
0
You'll most likely want to use:
FileReader
and BufferedReader
classes that work on any platform that Java supports. In fact, because Java runs on a virtual machine, simple IO is inherently platorm, OS independent. See this reference for ideas.

Chimera
- 5,884
- 7
- 49
- 81
-
Thanks for answer, but I didn't mean this! I've made my question clearer than before! – Andrea Tucci Jul 14 '12 at 16:21