Results 1 to 6 of 6

Thread: Properties file in java

  1. #1
    Join Date
    Nov 2009
    Posts
    356

    Properties file in java

    Hello,
    I would like to know how to use properties files. Here is my code, this is what I have tried till now.
    Code:
    Public static void hand(String args[]) throws Exception
    {
    String lang = new String(args[0]);
    String con = new String(args[1]);
    Local cur = new Local(lang, con);
    ResourceBundle msg = ResourceBundle.getBundle("Properties / MessageBundle, cur);
    
    FenetreAplic f = new FenetreAplic ();
    )
    Any help on this will be appreciated. Thanks in advance.

  2. #2
    Join Date
    Dec 2009
    Posts
    211

    Re: Properties file in java

    Hey,
    Even I was trying the same kind of a problem. If you have any solution for this then please do post back. Actually , I am trying this, for now I have with me is this, that is to do the things I use the following.
    Code:
    System.out.System.out.println("something");
    and I would like to:
    Code:
    System.out.System.out.println(Text1);
    do you have any idea how to achieve this, if you know then please post I am the interested here.

  3. #3
    Join Date
    Nov 2009
    Posts
    518

    Re: Properties file in java

    Hello,
    I have modified your code, you can try the following code. Here it is, see if this helps you
    Code:
    Public static void hand(String args[]) throws Exception {
      String lang = new String(args[0]);
      String con = new String(args[1]);
      Local cur = new Local(lang, con);
      ResourceBundle msg = ResourceBundle.getBundle("MessageBundle", CurrentLocale);
    
      String message = msg.getString("Text1");
      FenetreAplic f = new FenetreAplic(); 
    }

  4. #4
    Join Date
    Nov 2009
    Posts
    356

    Re: Properties file in java

    Hello,
    Well ok but how I use
    Code:
    String message = messages.getString("Text1");
    in other classes that do not know the class that contains the hand? I understand this, i guess. if not args [0] and args [1], I use Jcreator So how do I add values in it? and he puts what he defaults? If you have other alternative method for this then please do post back. I am interested in this topic.

  5. #5
    Join Date
    Nov 2009
    Posts
    446

    Re: Properties file in java

    Hello,
    You have two options:

    - Or pass the values retrieved from your ResourceBundle class to class,

    - Within each class that needs access, repeat the code, or write a class that returns the desired message.

    Otherwise default args [0] and args [1] does not contain anything that is even worse in the args array is not initialized, therefore null. But args [0] does not exist, then args [0] causes an error type IndexOutOfBoundException. As for JCreator I do not know so I can not help you, but I'm sure that looking a bit you'll find, because most of the time is fairly intuitive and straightforward.

  6. #6
    Join Date
    Dec 2009
    Posts
    211

    Re: Properties file in java

    Hello,
    Ok thank you, I'm going to create another class to handle it, it will be easier than passing the value from class to class. Good for the rest I'm going because I actually see this exception. For doing the same thing, that is for the same working of the code, if you have any other alternative , then please let me know, it would be great for me. Thanks you in advance.

Similar Threads

  1. Eclipse and File Properties
    By Ash maker in forum Software Development
    Replies: 5
    Last Post: 08-03-2010, 09:39 AM
  2. Java properties / variables dynamically
    By Miles Runner in forum Software Development
    Replies: 5
    Last Post: 04-03-2010, 11:31 AM
  3. Properties of .ini file
    By Logan 2 in forum Software Development
    Replies: 5
    Last Post: 25-01-2010, 01:43 PM
  4. Cannot View AVI file Properties
    By Balgovind in forum Windows Software
    Replies: 2
    Last Post: 25-05-2009, 12:48 PM
  5. C#.net how to access properties of a file?
    By Henrietta in forum Software Development
    Replies: 1
    Last Post: 11-08-2008, 01:47 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,724,928.42784 seconds with 17 queries