Using the Util package on the use of the properties package on it, so that we have the configuration, write to a properties file more intuitive.
Here is an example of a more ugly case:
PackageCom.property;ImportJava.io.File;ImportJava.io.FileInputStream;Importjava.io.IOException;Importjava.util.Properties; Public classMainproperty { Public Static voidMain (string[] args)throwsIOException {Properties Properties=NewProperties (); //PathString url=system.getproperty ("User.dir"); System.out.println (URL); File Dire=NewFile (""); String URI=Dire.getcanonicalpath (); System.out.println (URI); //Package NameString packstring= (NewMainproperty ()). GetClass (). Getpackage (). GetName (); System.out.println (packstring); FileInputStream FIS=NewFileInputStream (url+ "\\src\\main\\java\\com\\property\\my.properties"); Properties.load (FIS); Fis.close (); System.out.println ("SiteName:" +properties.getproperty ("sitename")); System.out.println ("SiteURL:" +properties.getproperty ("SiteURL")); }}
Really ugly, there is no automatic access to the current configuration path. Here you can write one yourself, such as spring-like to get the configuration file under the current path Classpathxmlapplicationcontext, and so on when you write it. Also missing a properties file, which write a few of their own desired key value pair, and then print their own content.
Java using the Properties file