Good afternoon, there is a task, to read the settings when the program starts ... I do not understand how to implement it (java) ... here is the application:
public class MainClass { public static void main(String[] args) { Properties myProp = new Properties(); InputStream is = null; try { is = MainClass.class.getResourceAsStream("/my.properties"); myProp.load(is); FileWriter fileWriter = new FileWriter(myProp.getProperty("outPath")+"text_out.txt"); fileWriter.write(myProp.getProperty("text")); is.close(); fileWriter.close(); System.out.println("Fiel text_out.txt created"); Thread.sleep(5000); } catch (Exception e) { System.out.println(e.getLocalizedMessage()); } } }
the essence is this, there is a certain file my.properties there are 2 lines in it, the first is the text, the second path to the file where this text should be placed:
text = Привет! как дела! outPath = /Users/myMac/Downloads/rrr/
The structure of the project is as follows (going to maven):
main java MainClass resources my.properties
I create with the help of maven (package) executable jar file, I start everything works, but the same text is always displayed and the file is created in the same place ...
and moving the jar file anywhere, it always works ...
as far as I understand, my.properties is packed into a jar file, and from there infa is read ...
Attention is the question of how to write a program so that the program reads data from (suppose) a nearby file, and when the information in this file changes, does it react to these changes ???