Write a properties file in a package, of my own project.

It is kinda hard for me to safe my checkSameFile.properties file inside a package of my own project.
                Properties properties = new Properties();
          FileOutputStream fileOutputStream = null;
          try {
               fileOutputStream = new FileOutputStream("checkSameFile.properties");
          } catch (FileNotFoundException e) {
               e.printStackTrace();
          try {
               properties.setProperty("directoryPathName", "K:/Muziek/Muziek");
               properties.store(fileOutputStream, "Two directory path names");
               fileOutputStream.close();
          } catch (IOException e) {
               e.printStackTrace();
          }This does work, but my checkSameFile.properties is saved in my project map outside the src folder.
I want to save checkSameFile.properties in my package 'application.checkSameFile' . It tried many things, but nothing works.
The most beautiful solution would be something like this.
                Properties properties = new Properties();
          FileOutputStream fileOutputStream = null;
          try {
               fileOutputStream = new FileOutputStream("application.checkSameFile.checkSameFile.properties");
          } catch (FileNotFoundException e) {
               e.printStackTrace();
          try {
               properties.setProperty("directoryPathName", "K:/Muziek/Muziek");
               properties.store(fileOutputStream, "Two directory path names");
               fileOutputStream.close();
          } catch (IOException e) {
               e.printStackTrace();
          }This doesn't work.
I hope someone can help me out. I thank in advance.

Ah ok thx for helping me. It was kinda stupid of me i guess.

Similar Messages

  • How we write into properties file using get class method

    Hi
    I want to set some value into properties file using given code
    can any one please tell me how i can do this.
    property file
    setting.properties
    Name     =     abc
    and code I use is
    java.io.InputStream oInputStream = this.getClass().getResourceAsStream("Setting.properties");
                   Properties obj = new Properties();
                   obj.load(oInputStream);
                   String myName = obj.getProperty("Name");
                   System.out.println("myName :"+myName);
                   obj.setProperty("Name","def");
                   FileOutputStream oOutput= new FileOutputStream("Setting.properties");
                   obj.store(oOutput, "");
    thanks.

    You can't.
    If you have properties that change dynamically, you should not be using a properties file that sits in the classpath, you should be using Preferences, or a properties file that sits in some application or possibly even user directory, but not one in the classpath. The proper way to do this, would be to have a properties file in your jar (or otherwise in your classpath) that contains the defaults, and another one outside of the classpath in one of the twwo above mentioned areas, then, you read the default one only if the other doesn't exist, or you read the default one first, then read the other overwriting the values from the defaults.
    Don't forget to save the properties again (right after loading if you loaded, or always load, the defaults) after every change.

  • Write PROPERTIES file

    Hi there
    Im trying to write a properties file. My out put (the content of the PROPERTIES file should be exactly as follows)
    #Wed Nov 30 05:35:37 LKT 2005
    java.naming.provider.url=jnp://localhost:1099
    java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
    Here is the code Im using (Just a demo)
    import java.util.*;
    import java.io.*;
    public class test{
         public static void main(String arf[]){
            try{
                Properties defaultProps = new Properties();
                    FileOutputStream out = new FileOutputStream("defaultProperties.PROPERTIES");
                    defaultProps.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
                    defaultProps.setProperty("java.naming.provider.url","jnp://"+"localhost"+":"+"1099");
                    defaultProps.store(out, null);
                    out.close();
              catch(Exception e){}
    }When I run this the propeties file it contains the following. Please note the (\ )before every colon(:) in jnp\://localhost\:1099. I need to eliminate this \ and write only the : to the PROPERTIES file as mentioned above.
    #Wed Nov 30 05:35:37 LKT 2005
    java.naming.provider.url=jnp\://localhost\:1099
    java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
    Some body please help me to eliminate this \.

    Why are you trying to get rid of the "\" before the colons? The "\" is needed to preserve the Properties file format. Read the API for the "load" and "store" methods.

  • Regarding properties file

    Hi,
    I want to know the details regarding properties file [wsdl].
    How to write a properties file and other details about it.

    key1=value1
    key2=value2
    key3=value3
    that's all there is to it

  • Reading properties file in Webspehere

    Hi All,
    I am using a web application which uses a prperties file containing JNDI url (DB userID and password also ). This properties file is not packaged inside the war and kept in a folder named config. I have worked on App servers like Resin and Tomcat, I usually place the config folder in the server root, lets say Tomcat\config or resin\config and it works fine with both.
    But when it comes to Webspehere, I have kept the folder in WAS Root/config and even WAS Root/Appserver/profiles/server name(eg. Appsrv01)/config, but it seems not to be working.
    - Is there any other place where I'll have to place the folder ?
    - Are there any configuration changes that need to be done for the properties file to be read ?
    just to give you idea of the logic I use to read the properties file is :
    public class PropertyManager
    Properties property;
    public PropertyManager()
    // create and load default properties
    try
    property = new Properties();
    property.load(new FileInputStream("config/systemProperties.properties"));
    catch (IOException e)
    e.printStackTrace();
    public String getProperty(String propertyKey)
    String value = property.getProperty(propertyKey);
    return value;
    public static void main(String[] args)
    System.out.print(new PropertyManager().getProperty("user"));
    Can anybody help me regarding this ??
    Thanks in advance,
    Cheers,
    Partha

    Well there are two things involved here one of them is folder/directory permissions applied on the location which you are talking about.I'd say you might have to test on the user profile on which WAS service is currently running and a recommendation would be if i were i'd have posted in around respective user.home folder on to which i'd nt any messups with permissions on folder.

  • Doubt on writing a properties file in to jar file

    hi,
    I have a jar file. In that jar file, I have a folder, named '/data/'. In this data folder i want to write a properties file. how to write?
    i was tried using the store method but i did not get it
    can any one help me out.
    thank you.

    You want to place the log4j.properties inside the .jar? You can read the log4j.properties inside the jar and give the Properties to log4j like this:
    String propertiesFile= "pathInJar/log4j.properties";
    InputStream in = getClassLoader().getResourceAsStream(propertiesFile);
    if (in != null)
        Properties props = new java.util.Properties();
        props.load(in);
        PropertyConfigurator.configure(props);
    else
       //PropertiesFile not found! (Handle the problem)
    }

  • EJB project IDE build dos not include properties files

    We have property files also which we want included as part of the build process
    for EJB projects but if we use the IDE build it does not include them. We have
    to therefore export the IDE build and customize it to include *.properties like
    this
    <zip basedir="${dest.path}" zipfile="${ejb.outputJar}" encoding="UTF8"> <!-- JARs
    filenames are encoded UTF8 --> <zipfileset dir="${project.local.directory}" includes="*.properties"
    /> </zip>
    which causes a problem for us because the exported build file is specific to a
    user's local PC and cannot be used in a team environment.
    How can we have the IDE build include all the files within an EJB project i.e.
    include properties files also.

    Hey Jamie,
    Currently there is no support to include other .properties files into
    the internal build. There's a build.properties that you get as part of
    an EJB project which you could place your values into and use that as
    your template for your team based development and check that into your
    source control.
    If you'd really like to get gross and hack Workshop a little bit you
    could modify the default EJB project template to use your .properties
    file for every EJB project you create. This would then splat a copy of
    your .properties file into the root of the EJB project.
    To do that you'd go to {your BEAHOME}\workshop\templates and crack open
    the ejb-project.zip template zip file and merge your settings into the
    existing build.properties file. This has the same
    effect as replacing the .properties file after you've created your
    project only it keeps you from having to perform that step each time.
    The downside of this is that each person on your team would then have to
    update that template zip file in their workshop installation. (I'd make
    sure to backup the original template file before performing this
    activity so you can always go back to the original template).
    Hope this helps,
    -Michael
    Jamie wrote:
    We have property files also which we want included as part of the build process
    for EJB projects but if we use the IDE build it does not include them. We have
    to therefore export the IDE build and customize it to include *.properties like
    this
    <zip basedir="${dest.path}" zipfile="${ejb.outputJar}" encoding="UTF8"> <!-- JARs
    filenames are encoded UTF8 --> <zipfileset dir="${project.local.directory}" includes="*.properties"
    /> </zip>
    which causes a problem for us because the exported build file is specific to a
    user's local PC and cannot be used in a team environment.
    How can we have the IDE build include all the files within an EJB project i.e.
    include properties files also.

  • WSAD : loading properties file from EBJ project

    Hi,
    I am trying to load properties file contains database parameters into my EJB project. I am using WSAD as IDE tool
    can you please help me with following.
    1. where to place the .properties file physically ?
    2.how to load the file to my EJB/DAO classes
    3.can i use the same location to place log4j.properties file as well ?
    I have tried doing in different ways but none is working.
    thank you
    Narendra

    got it working , for information pl go to the following page and section "Using log4j in an EJB Application"
    i have followd same steps for loading my properties file .
    http://sys-con.com/story/?storyid=43413&DE=1

  • Flex properties file

    Hi. I've got some URL's in my Flex app that I'd like to pull
    into a properties file; the values will differ between our
    development and production systems. How do you get/set a properties
    file in Flex? Thanks.

    The Flex project properties files do not exist at run-time.
    Are you speaking in general, of needing to initialize your
    application at run time with some values?
    The simplest way to do this is to pass the values into the
    Flex app from the html wrapper, via flashvars. You just need a
    different version of the wrapper for each different deployment.
    This is the way I do it. It also makes it easy to have different
    launch configurations in FlexBuilder.
    Another solution is to use HTTPService to load an xml file
    containing your initialization data. Of course that way you have to
    have an URL for the HTTPService...
    Tracy

  • Where to put the properties file

    I am a new user of NetBeans6.0, I am making a simple application for user registration. I have coded everything but when I run project I get error caused by the dao.properties file load problem.
    I have put the dao.properties file inside the classes directory(where all java class files are build after running the project) of my web application directory( I didn't create this directory though, it is automatically created by IDE), I think there is a problem with its path.
    where should I put the dao.properties file so that when I run the project the Tomcat automatically find it and also, what the settings I should do?
    actually, I have referred to BalusC'd  DAO tutorial: the data layer but that comes in use when we are working off the IDEs, In my case since I am using Netbeans so it may be different from that one.
    if someone already done that then please let me know

    ok, but will it work if I upload the project in a remote host?
    lets talk besides IDE, as in your DAO tutorial you have instructed to put the properties file somewhere in root of the classpaths. ok, it will work on a local computer cause there is classpath setting but since remote host doesn't know about that property file and we cant set classpath at remote host(I am not sure though if we can) then how will it work at remote host.
    how the server at remote host comes to know about that property file?
    In my case since I have made the project using IDE and everything regarding classpaths have been set automatically(IDE done itself), but at remote host these sort of settings are not done then how the project will run?
    if I have described my problem incorrectly then please consider it as it is supposed to be.

  • How do I load a properties file that is in the same package?

    I have the following package:
    com.company.ldap
    In the package I have:
    main.java
    settings.properties
    I want to load the values in the settings.properties file in code, such as:
    propertiesFile = "settings.properties";
            try {
                properties.load(new FileInputStream(new File(propertiesFile)));
            } catch (IOException e) {
                ... error logging logic ...
            }I keep returning "The system cannot find the file specified".
    How do I properly load a properties file in a class file within the same package?
    Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Put the file in the classpath (such as in the parent directory of com/company/ldap). Then obtain an input stream to that file like this:
    InputStream stream = getClass().getResourceAsStream("/settings.properties");
    Then use that stream in the properties.load method. Remember to close the stream as well.

  • Package Properties file not Found SCC

    Hello everybody,
    i need some help i m having this issues : i can't access to my packages files deployed on the default domain it's shows me this error : "Failed to get the package List"
    i checked the domain log i found this error;
    Subsystem=Error  Application ID=, Application Connection ID=, User=, Correlation ID=, Package=, MBO=, Operation=, Thread ID=80, Node ID=WIN-1CMM6LM48GD, Error=com.sybase.djc.SystemException was thrown by transaction com.sybase.sup.server.sis.SISNotificationProducerTask.run()\ncom.sybase.djc.SystemException: Package properties file not found: d1_bapi_fl.1_0
              at com.sybase.sup.server.sis.SISNotificationProducerTask.run(SISNotificationProducerTask.java:233)
              at com.sybase.sup.server.sis.SISNotificationProducerTask_DJC.access$001(SISNotificationProducerTask_DJC.java:4)
              at com.sybase.sup.server.sis.SISNotificationProducerTask_DJC$1.invoke(SISNotificationProducerTask_DJC.java:25)
    thank's .

    treat .properties files just like a class file :)
    if /classes/ is in your classpath and in that directory you have an x.properties file then:
    ResouceBundle.getBundle("x");
    will return it...
    if the x.properties file is in the /classes/com/company/props/ directory then this will act like a package name and
    ResouceBundle.getBundle("com.company.props.x");
    will return it ;)

  • 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..

  • Packaging font.properties file.

    Hello All,
    I am developing a cross-platform application and I wat the Java runtime to use my own font.properties file. How can I specify that file using -D switch?
    (for example, for logging i write, java -Djava.util.logging.config.file=logging.properties MyApp so, is there a similar option for font.properties?)
    Thanks in advance,
    Ghaznavi

    Any body please help!
    Ghaznavi

  • [svn] 2200: The main package will now also include the ja swc' s and properties files.

    Revision: 2200
    Author: [email protected]
    Date: 2008-06-24 07:46:04 -0700 (Tue, 24 Jun 2008)
    Log Message:
    The main package will now also include the ja swc's and properties files.
    -it will not include the samples, these will still be in the ja zip
    bug:http://bugs.adobe.com/jira/browse/SDK-15852
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-15852
    Modified Paths:
    flex/sdk/branches/3.0.x/build.xml

    Hi,
    First up thanks for helping out, I really appreciate it.
    Is there a way to change that or should I simply add the file to the Classpath?
    The config file at present sits in c:\Temp\ESFGFL\servicelayer\config\maysqlconfig.properties with the code in the servicelayer directory.
    My classpath is set as .;C:\Program Files\Java\jre6\lib\ext\QTJava.zip;C:\Program Files\Java\jre6\lib\javamail-1.4.2\mail.jar
    What do I need to change here? Ultimately te code will be on a servera nd so will the config file but learning some lessons by testing locally is proving invaluable.
    Thanks again for your help
    nathj

Maybe you are looking for

  • How can I use the photos from iphoto to display in contacts?

    Contacts has a space for a photo.  At one time I knew how to populate this space with photos from iPhoto. Currently my choices are to use an icon or take a pic with the camera. How can I add the photos from iPhoto to the choices for populating the "C

  • Set the name of cell or cells' range for a report and when export it to excel the names will be defined.

    Hello, I have an C# application that exports report from Reporting Services to Excel files. I would like to know if there is a possibility to set the name of the cell or range of cells in the report (via Report Builder or somewhere else) and when ope

  • Can we write scripts to create new transitions?

    Hello, I use photos as media a lot, I would like to have a couple more effects and transitions, like Rotate, Rotate Out, Disappear/Size Down/Size In. Anyone out there have any thoughts on this or am I just saying I need Final Cut. I'd like to avoid t

  • Maintain a Webi schedule outside of BOE

    My requirement is this: A single parameterised webi document needs to link to instances of itself, passing in parameters to input prompts from parent to child.  In order to aid performance, the intention is to schedule the document so that an instanc

  • To get segtyp if an IDoc from its segnam

    hi all, i have a query, i need to get segtyp (of an Idoc from) frm its segnam. i have used all IDOC related table like EDID4, EDIC, EDIS etc but have not been able to find any solution till now to solve my query. please help. Edited by: Kriti Nigam o