Answer the question
In order to leave comments, you need to log in
How to use java code to open a text file for example?
When you run the code, a text file should open, or, in general, any file that is specified in the path. Or open a browser. Is this possible to do? If yes, then give an example for Windows, I will be very grateful!
Answer the question
In order to leave comments, you need to log in
To the question of running Windows programs through Java, you can look here:
How to run programs through cli on Windows - https://superuser.com/questions/494538/how-do-i-op...
To the question of how to execute commands in cmd - https://stackoverflow.com/questions/15464111/run-c... Have a
look at the Process & ProcessBuilder classes. The link above shows an example of their use.
Or open a browser.
java selenium {your_browser}
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
desktop.open(new File(filename));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question