Java properties file

Hi ,
I am using trying to write data to a java properties file , by using the setProperty method and somehow the order of the data is not by the order of inserting it ,Is there a way to use the setProperty method and still keep the order of data in the file after storing it.
Thanks.

Eddie404 wrote:
I am using trying to write data to a java properties file , by using the setProperty method and somehow the order of the data is not by the order of inserting it ,Is there a way to use the setProperty method and still keep the order of data in the file after storing it.It shouldn't matter what order the Properties class uses to write its data. If it does, you aren't doing something right.
If the order matters, that suggests that somebody is responsible for maintaining the properties via a text editor, or something like that. In which case you shouldn't be using a Properties object which modifies the property file. But as soon as you start having two different processes to maintain the file, you're going to run into trouble. So simplify your life and stop doing that. Either maintain it through the program, or through the text editor, but not both ways.

Similar Messages

  • Static lookup lists:read data from a Java *.properties file

    Hi
    i need to make static lookup lists i am using read data from a Java *.properties file
    i am using the Class "PropertyFileBasedLookupViewObjectImpl" that wrote by Steve Muench in ToyStore.
    but i need to use the default language for that i update the loadDataFromPropertiesFile()
    method to find the correct properties file
    String temp=Locale.getDefault().getLanguage();
    String propertyFile =
    getViewDef().getFullName().replace('.', '/')+"_"+temp+ ".properties";
    the problem:
    For English(TEST_en.properties) it is good and working
    For Arabic(TEST_ar.properties) read from correct file _ar.properties
    but the dispaly character is wrong
    When Debug
    In the File 1=دمشق
    In debug 1=/u32423

    Depending on your use case you can either use a programmatic VO or directly expose the JV class as a data control.
    http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_36/jdtut_11r2_36.html

  • How to configure Java Properties File location in WLW

    How do we tell Workshop 7.0 where to look for Java properties files (loaded by
    PropertyResouceBundle in code) ?
    Thanks,
    Ray

    Ray,
    The build number indicates that you have not upgraded to Service Pack 2 of
    version 7.0. I will strongly recommend you to do so. That will shield you
    from the issues which were fixed in the 2 service packs.
    Regards,
    Anurag
    "Ray Yan" <[email protected]> wrote in message
    news:[email protected]...
    >
    Raj,
    We are using WebLogic Workshop Build 7.0.1.0.0829.0 on Windows 2000.
    We shut down the WebLogic Server on Solaris 2.6, log off, log back on,startWebLogic
    in production nodebug mode, and re-run jwsCompile on the same source code.The
    error does not occur anymore. Everything seems to be fine now.
    Thanks,
    Ray
    "Raj Alagumalai" <[email protected]> wrote:
    Hello Ray,
    Can you let me know if you are using the GA version of WebLogic Workshop
    or
    if you have the latest Service Pack.
    Thank You,
    Raj Alagumalai
    WebLogic Workshop Support
    "Ray Yan" <[email protected]> wrote in message
    news:[email protected]...
    Anurag:
    Thanks for your response!
    By moving the property files to WEB-INF/classes from WEB-INF, we arealmost there.
    But we have a follow up problem. We use a static initializer to loadthe
    log4j
    property file like this:
    static {
    try {
    ClassLoader cl= (new Log()).getClass().getClassLoader();
    InputStream is = cl.getResourceAsStream(logfile);
    Properties props = new Properties();
    props.load(is);
    PropertyConfigurator.configure(props);
    } catch (Exception e) {
    e.printStackTrace();
    When we run jwsCompile, we keep getting this:
    Compiling: com/****/TestWS.jws
    weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[weblogic.management.Admin
    may only be used on the Server ]
    at weblogic.management.Admin.getInstance(Admin.java:104)
    at
    weblogic.security.internal.ServerPrincipalValidatorImpl.getSecret(ServerPrin
    cipalValidatorImpl.java:79)
    at
    weblogic.security.internal.ServerPrincipalValidatorImpl.sign(ServerPrincipal
    ValidatorImpl.java:59)
    at
    weblogic.security.service.PrivilegedActions$SignPrincipalAction.run(Privileg
    edActions.java:70)
    at java.security.AccessController.doPrivileged(Native Method)
    at
    weblogic.security.service.SecurityServiceManager.createServerID(SecurityServ
    iceManager.java:1826)
    at
    weblogic.security.service.SecurityServiceManager.getServerID(SecurityService
    Manager.java:1839)
    at
    weblogic.security.service.SecurityServiceManager.sendASToWire(SecurityServic
    eManager.java:538)
    at
    weblogic.security.service.SecurityServiceManager.getCurrentSubjectForWire(Se
    curityServiceManager.java:1737)
    at weblogic.rjvm.RJVMImpl.getRequestStream(RJVMImpl.java:434)
    at
    weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:
    88)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :255)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :230)
    at
    weblogic.jndi.internal.ServerNamingNode_WLStub.lookup(Unknown
    Source)
    atweblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:337)
    atweblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:332)
    at javax.naming.InitialContext.lookup(InitialContext.java:345)
    at weblogic.knex.bean.EJBGenerator$1.run(EJBGenerator.java:101)
    at
    weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
    r.java:780)
    atweblogic.knex.bean.EJBGenerator.lookupAdminHome(EJBGenerator.java:84)
    atweblogic.knex.bean.EJBGenerator.ensureAdminHome(EJBGenerator.java:122)
    at weblogic.knex.bean.EJBGenerator$6.run(EJBGenerator.java:660)
    at
    weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
    r.java:821)
    atweblogic.knex.bean.EJBGenerator.generateJar(EJBGenerator.java:482)
    at
    weblogic.knex.dispatcher.DispJar.generateJar(DispJar.java:401)
    atweblogic.knex.dispatcher.DispCache.ensureDispUnit(DispCache.java:695)
    atweblogic.knex.compiler.JwsCompile.compileJws(JwsCompile.java:872)
    at
    weblogic.knex.compiler.JwsCompile.compile(JwsCompile.java:619)
    at weblogic.knex.compiler.JwsCompile.main(JwsCompile.java:109)
    ejbc successful.
    Generating EAR ...
    The EAR was generated and we can even deploy it on Solaris. But whatdoes
    the
    AssertionError mean?
    Thanks,
    Ray
    "Anurag Pareek" <[email protected]> wrote:
    Ray,
    ResourceBundle looks for the properties file in the current thread's
    classpath.
    Since a Workshop webservice's project is nothing but a webapp, the
    properties files can be kept in the WEB-INF/classes directory, which
    is part
    of the webapp classpath.
    You can also use
    Thread.currentThread().getContextClassLoader().getResourceAsStream("MyProp
    s
    properties"); to get access to the properties file.
    Thanks,
    Anurag
    "Ray Yan" <[email protected]> wrote in message
    news:[email protected]...
    How do we tell Workshop 7.0 where to look for Java properties files(loaded by
    PropertyResouceBundle in code) ?
    Thanks,
    Ray

  • How to load Java properties file dynamically using weblogic server

    Hi,
    We are using Java properties file in Java code. Properties in java properties file are frequently modified. If I keep these properties file in project classpath or as part of war, I will have to redeploy application after each change.
    We are using Weblogic Server.
    Can you please suggest me how can this properties file be loaded at weblogic server startup. Then in that case, how to refer property file in Java code?
    What is the best practice for this?
    Thanks,
    Parshant

    Another alternative is, keep the property file in any pre-defined location. Write a class which reads the properties from the file and returns the one which is requested by caller and deploy this class. Whenever you have to change the properties just update the property file on server and next call to fetch the property should return the updated one.
    Downside of this approach is file I/O everytime. To overcome that you can actually "cache" the properties in a hashmap. Basically when any property if requested, first check the hashmap, if not found then only read from property file and also update in hash map. Next time same property will be returned from hash map itself. The hash map will be cleared at every server restart since its in the memory. You will also need to build a method to clear the hashmap when you update the values in the property file on server.
    This solution would be suitable for small size files and when network overhead of calling a DB needs to be avoided.

  • Need help for how to putting arabic content in java properties file

    Hi all,
    we have to support arabic in Java application.
    For that we are using java propeties file where key and value pair is used.
    In the Microsoft excel sheet arabic content is coming properly from right to left direction.
    When same thing is copied and paste in java properties file contents direction is reversed that is it is coming from left to right as in english.
    Please help how to put the arabic contents in propeties file
    Regards
    Vidya

    So in terms discussion.
    First I would suggest that you get a hex editor and validate exactly what is in the properties file. It appears to me that you are using one or more editors that are adjusting the display for you and thus that makes it hard to determine where the problem is. A hex editor should not adjust the display. Although even then you might want to right a simple java app and have it read bytes and print them just to validate that the hex editor isn't doing something.
    Only after you are exactly sure how the bytes appear in the file then proceed with other steps.
    For the java GUI only test the following.
    1. Properties file has it left to right then the java GUI displays it correctly right to left or not?
    2. Properties file has it right to left then the java GUI displays it correctly right to left or not?
    Myself I would expect that 2 should be the correct way to implement this. However that is dependent upon you correctly invoking the api as well. So if 2 is not working then you might want to look at the api. It might also have something to do with GUI display properties (of which I know even less.)

  • Using variables in a java.properties file

    Hi,
    I have a .properties file that I'm using to configure an app. I was wondering if there is a way to set a property = to an already defined property and more. So for example:
    app.siteroot=c:\tomcat\webapps\myapp
    app.templatefolder= app.siteroot + \templates
    I know the above won't work but is something like this possible?
    Thanks
    krebsnet

    I don't think there's anything in the core APIs that let you do anything like that. You can probably find something 3rd party though.
    I know ant lets you do that:dir1=foo
    dir2=${dir1}/bar It's possible that the code that does that is available in a library from jakarta. Or you could check sourceforge, or mindproducts (or is it just mindprod?)

  • Direction of middle eastern languages in properties file

    Hi,
    I am hoping someone can point me to an authoritative source or document specifying which direction the Hebrew / Arabic / Farsi text should be entered in java properties files. That is, does it follow the natural direction of the script (right-to-left) or does it follow the direction of key (left-to-right)? I have tried searching without much luck.
    For example:
    sample.properties
    # english properties file
    sample.text=hellosample_he.properties (for the purposes of demonstration I am using english characters, in reality this would be the Hebrew and escaped)
    # hebrew properties file using the natural direction (right-to-left)
    sample.text=molahsOR is it
    # hebrew properties file using the english direction (left-to-right)
    sample.text=shalomthanks in advance,
    Ben

    Why don't you just do a test? It's a simple matter of applying a few Arabic strings to a properties file and checking how it looks in the UI.
    Or try thinking about it for a couple of seconds - how would a translator (anybody creating the bidi localized versions) create the left-to-right version you describe?
    Anyway, the answer is that bidi text in properties files is entered and stored the way bidi text is entered and stored in any other normal text file.

  • Accessing .properties file from java code

    Hi,
    I want my java code in a Tomcat Web Application to access values in a custom .properties file.How can i do it.
    Any sample code / suggestions welcome.
    Thanks
    Vignesh.

    ResourceBundle vResourceBundle = ResourceBundle.getBundle("database", Locale.ENGLISH);
            sDriverName = vResourceBundle.getString("database.DriverName");
            sDbURL = vResourceBundle.getString("database.DriverUrl");
            sDbUser = vResourceBundle.getString("database.UserName");
            sDbPasswd = vResourceBundle.getString("database.PassWord");Where "database" is the name of the property file. ie., database.properties.
    the content of the database.properties file
    # Properties to access dabase                 
    database.UserName = scott
    database.PassWord = tiger
    database.DriverName = oracle.jdbc.driver.OracleDriver
    database.DriverUrl = jdbc:oracle:thin:@nn.nn.nn.nn:port:orartgnull

  • How to use .properties files in Webdynpro Java code?

    Hi all,
      I want to use a logon.properties file when I initial a JCO connection pool in my webdynpro DC (JCO.addClientPool()),but  I found when I deployed this DC to the server, it always giv e me an FileNotFoundException. So I donot know how to deploy a .properties file to the server and how to access this file in my Java code?
    Thans and Best regards
    Deyang

    Hi,
    1) put .properties file to your packege under src\packages folder (src\packages\com\sdn\properties\jco.properties)
    2) load property:
         final InputStream is = getClass().getClassLoader().getResourceAsStream("com/sdn/properties/jco.properties");
         final Properties properties = new Properties();
         try
              properties.load(is);
         catch(Exception e)
              wdComponentAPI.getMessageManager().reportException(new WDNonFatalException(e), false);
    Regatds Maxim R.

  • Java.lang.NullPointerException   in the code to read a properties file

    I have written the following code to read a properties file...........
    <b>
    public Property(String fileName)
        try
           InputStream is = MyClassName.class.getClass().getClassLoader().getResourceAsStream(fileName);     
           prop.load(is);
           is.close();
        catch (Exception ex)
            System.out.println("The Exception is:        " + ex.getMessage());
            ex.printStackTrace();
    </b>
    But this code is giving <b> java.lang.NullPointerException </b> at <b> prop.load(is) </b>
    please help me....
    regards
    Brahmachaitanya

    hi,
        If you are loading a resource (property) file from a jar file you can use
    getResourceAsStream("com/test/test.properties").
        if the propery file is in outside of your jar file . you can use
    Property portalProps = new Property ();
    try {
                   FileInputStream fileInputStream = new FileInputStream("<FilePath + FileName>");
                   portalProps.load(fileInputStream);
                   fileInputStream.close();
              } catch (IOException e) {
                   //Log the error
    refer the following link for more details
    http://www.javaworld.com/javaworld/javaqa/2003-08/01-qa-0808-property.html

  • Java Internationalization and .properties files

    Hi everyone,
    Isn't it problematic that the way to internationalize your java apps ( .properties files ) doesn't support UTF-8 and you have to user gibberish looking unicode escapes. Some will say that you don't need to write and the converters or editors will handle the ascii conversion but the requirement for such a intermediate process doesn't seem right. Sometime you have to edit some string on the server and it should be human readable using text editors that support UTF-8. I thought loadFromXML and storeToXML methods that came with java 1.5 seemed to solve the problem but than noticed that PropertyResourceBundle doesn't support xml properties files. Is backwards compatibility the reason that properties files aren't utf-8 by default?
    Thanks
    Bilgehan

    Try PRBeditor (http://prbeditor.dev.java.net).

  • Configure properties file that java file uses in OSB.

    I have a jar file consisting of java files which maintain the session id in the queue. One main jar depends on 3 more jars for logging.
    Also java files in the jar depends on the *.properties file to read the queue length dynamically.
    I need to access the main jar from osb proxy server. I used java callout to access the java method provided in the main jar.
    My question is: where should I place *.properties which is used by java class, in the osb folder. I don't see how I can add *.properties in the osb console.
    Your timely help is greatly appreciated.

    sudheshna wrote:
    another java class which loads property file...I'm understanding that you don't have way to modify this +"another java class"+, but you have to figure out what strategy it uses to pick up the properties file... classpath? environment variable? absolute path? relative path?
    If the file needs to be on the classpath (a common strategy) then you can just place the it in %DOMAIN_HOME%\config\soa-infra... This one is usually in the classpath... Other option is to change setDomainEnv.cmd(setDomainEnv.sh) to add a directory to the classpath and place the file there...
    Hope this helps...
    Cheers,
    Vlad

  • Properties files in a Java package not included in DC build

    We are developing a Portal Standalone DC and i have a JspDynPage component within it. and i need to do internationalization in  it. so as part of that i want to keep multiple resource bundles(properties) so that i could manage my properties files easily, For example
    MSS.properties
    MSS_es.properties
    ESS.properties
    LSO.properties
    since portal by default has no way to do this bcos it allows only one resourcebundle to specify in portalapp.xml file, i have kept the resource bundles in java package like
    com.companyname.portal.resources.
    when i export from NWDS with selection of "i want to add non java resources into jar " option from windows->preferences->enterprise portal ->application development studio, it exports all the properties files as part of the par and everything works. but when i do the DC build it ignores all my properties files and it is not working. any suggestions on how to resolve this??? does SAP provide any other way of handling multiple properties files inside a PAR?????

    We are using NWDS 2004 SP19.  and yes i have defined three default SCs as dependencies. I tested with 2004s NWDS and it seems work fine. I am able to resovle this issue by moving my properties files into another java DC and create public part in java DC and use those public parts in Portal application DC.
    So The problem of not including the properties files into Jar seems to be issue only in Portal Application DC not in Java DC. thanks everyone for the quick responses..

  • Passing Arguments/Properties File to SUN JAVA ONE WEBSERVER at startup

    We are porting a Java App currently running on an Orion Web Server to Sun Java One Web Sever.
    We have found that with the various java application servers we've used over the years, that each want to find the properties file in a different spot. They way we've got around this is that we start Orion with a -D option to java to set a system property called cdsProps. Example: java -DcdsProps=Path_to_properties_file. We then reference that cdsProps arugment throughout the java code so it knows where to find the properties file. Because the cdsProps argument is used thoughout the java code, if the -D option is not used when starting the webserver to point to the properties file, the website will not function properly.

    in the case above, the command line arguments are passed in the aaaaaaaaaaaaaaaaaaaaaaarggggggggggs array
    you probably want aaaaaaaaaaaaaaaaaaaaaaarggggggggggs[0] for the filenameAm not sure i understand, do you mean i must change the param of the main method to String[] args[0] as this resulted in error when i did so. Or do you mean at command line instead file simply being passed to the Compressor program as
    "java Compressor < examplefilename"
    It has to be "java Compressor < examplefilename[0]" ?
    If you could expand on this, would be grateful,
    Thanks.

  • Passing properties file to java

    I have this program that I want to accept a propertie file like thid
        public static void main(String args[]){
             CrsCodeGenerator codegen;
            if(args.length>=1)
                codegen = new CrsCodeGenerator(args[0]);
            else
                codegen = null;
            when I do
    java CrsCodeGenerator farouk.propertiesi get
    java.lang.NoClassDefFoundError: farouk/properties
    Exception in thread "main"
    Java Result: 1How should i do it?

    gcameo wrote:
    that is all that shows in NetbeansI really doubt that you are trying to launch CrsCodeGenerator in that case. Since it looks like you are trying to launch the class farouk.properties
    Kaj

Maybe you are looking for

  • How to Schedule an Interactive report in Background?

    Hi Experts, The existing program  generates Pay-in-slip,in the selection screen i am giving company code(Parameter) and Dates(select-option) as input,this gives me a list of records(ALV) with check boxe's if i select the records and click on 'post' b

  • Messaging not synking with Gmail since thr 20th Oc...

    I have a little problem with Nokia Messaging, for some reason messaging does not download any email from gmail since the 20th october, and even if i reinstall the app, it still only downloads the mail from the 20th. I haven't changed anything on the

  • ORA-00064 after changes processes, open_cursors in Oracle 10g Express

    Hi, I just run the following sql statements: alter system set processes=400 scope=spfile; alter system set open_cursors=5000 scope=spfile; After restart my computer, I can't connect to the oracle and in oradim.log i see the following error: ORA-00064

  • Problem about ModelSaved event in Network UI

    Hi, ALL:   I am using Network ui component in my Web Dynpro project. I write parameter mapping code for 'ModelSaved' event. But It doesn't works. I already define and mapping all necessary parameter for this. I also mapping 'NodeAdded' and 'NodeProps

  • Feedback form - specify who the sender is.

    Hello, I have a dreamweaver form that allows the user to fill in contact information and comments. When the form sends, it uses the "name" field as the sender info when I check it in my email account. It works properly on my email account through my