Friday 15 July 2011

java - Creating my own properties -


I am unsure about how to create more than 2 properties, I used the setProperty () method and when I have more than 2 Properties, Netbens threw a syntax error, which states that setProperty () method can have only 2 attributes, here is the code I have:

  / * * To change this template, select the device. Templates * and open the template in the editor. * / Import java.io.FileInputStream; Import java.io.IOException; Import java.util.Properties; Public class MyOwnProject {/ ** * @ Ultimate Command Line Argument * / Public Fixed Zero Main (string [] Args {FileInputStream propFile = null; Properties P = Null; // Set up new property object // "myProperties.txt" {propFile = new FileInputStream ("myProperties.txt"); P = new property (System.getProperties ()); P.load (propFile); } Hold (IOException e) {System.out.println (e); } // setProperty () method   

set a property through p.setProperty ("mykey20", "mykey30", "mykey40");

  // Set System Properties System.setProperties (p); // Display new properties System.getProperties (). List (System.out); }}   

Is there any way I can fix it? All help would be appreciated.

An asset is an important value added, emphasis on pair . It is not clear to me that what you are trying to do with three elements, but it can be as simple as you do

  p.setProperty ("mykey20" , "Somevalue20"); P.setProperty ("mykey30", "somevalue30"); ...   

Cheers,

No comments:

Post a Comment