The simplest way is to place the .txt
(eg. file.txt
) file by the jar, i.e., you can access it in your Java code:
File file = new File("file.txt");
In another way, if you want to launches the associated editor application (default for that file type in the current OS) for editing, you can try the next:
File file = new File("file.txt");
if (Desktop.isDesktopSupported()) {
Desktop.getDesktop().edit(file);
}