How use properties file

Hi i read about properties file in java .. i didn't get much more..
how can we use this in program.. what is the benefit..
anyone know any examples in site.please let me know about that

int count=getGoogleSearchCount();
public int getGoogleSearchCount(){
search keyword="http://www.google.co.ke/search?hl=en&q=java+properties+class&btnG=Google+Search";
// missing code
return count;
System.out.println(count);i ran the above code snipplet and guess the output?
291,000 results.
DONT BE LAZY.

Similar Messages

  • How to use properties file

    Hi,
    I want to use properties file in my application. I have kept properties file inside a directory called properties which is inside myProject(which is the parent directory of my project) i.e "myProject/properties".
    My java file where i want to call this properties file is inside the myProject/WEB-INF/src/java.
    How can i call the properties file from myProject/WEB-INF/src/java/PropertyReader.java
    I wrote java program in myProject/WEB-INF/src/java/PropertyReader.java like:::::
    ResourceBundle resBun = ResourceBundle.getBundle("Test", Locale.getDefault()); // Test.properties is inside myProject/properties
    resBun..getString("name");
    After running the program i am getting the following errors:::::
    Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name Test, locale en_US
    at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:836)
    at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:805)
    at java.util.ResourceBundle.getBundle(ResourceBundle.java:576)
    at PropertiesReader.main(PropertiesReader.java:4)
    What is the issue? How to use properties file?
    Waiting for reply.
    Thanks

    Still getting same exception. As you explained i tried like the below:::
    1. I am using ant as build tool.
    2. My properties file is for database configuration
    My properties file is::
    database.properties (inside myProject/properties)
    JDBCDriver=org.gjt.mm.mysql.Driver
    JDBCConnectionURL=jdbc:mysql://pmdbmysql:3306/bandwidthshaper?user=admin&password=admin
    My java package structure is
    WEB-INF/src/java
    WEB-INF/src/classes
    For build WEB-INF is the base directory and build.xml is inside the src directory
    In my build.xml i wrote the following lines for compilation::
              <target name="compile" >
                   <javac srcdir="src" destdir="src/classes" debug="true" debuglevel="lines,vars,source">
                        <classpath refid="class.path"/>
                   </javac>
    <copy todir = "src/classes" >
    <fileset dir = "../properties" />
    </copy>
                   <jar jarfile="lib/${project.jar.file}" basedir="src/classes"/>
              </target>
    I am copying properties file to the classes directory.
    Now in java file which is inside /WEB-INF/src/java, I wrote::
    try {
    Properties programProps = new Properties();
    InputStream is = getClass().getResourceAsStream("/database.properties");
    if(is == null)
    throw new IllegalStateException("Properties file missing ");
    programProps.load(is);
    System.out.println("driver name::::::: "+programProps.getProperty("JDBCDriver"));
    is.close();
    } catch(Exception e) {
    e.printStackTrace();
    After compilation in my classes directory i am getting database.properties file and my java file with package.
    At the time of running i am getting "java.lang.IllegalStateException: Properties file missing"
    Now tell me where is the fault. Why again i am getting exception.
    Thanks

  • How using mp4 files on final cut pro x

    a can't impot any mp4 (I don't want converter to mov) file in to fcp x.
    how using mp4 files on final cut pro x?

    MPEG-4 is  delivery framework and should never be used in production. At the very leasgt you should optimize the media when you import it.

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

  • How to read multiple files at multiple locations using properties file

    hi all ,
    in my code i take configuration input from a properties file ,it was really easy but what if there are multiple files ? how can i take configuration input (file path etc) from properties file in that case ? any suggestion ?

    thanks :) ..i am doing like this :
    String fName[]=new String[10];
              String choice[]=new String[10];
              String Delim[]=new String[10];
              ResourceBundle a = ResourceBundle.getBundle("input");
              String n=a.getString("NOF");
              try
                   for(int i=0;i<Integer.parseInt(n);i++)
                        fName=a.getString("PATH"+(i+1));
                        choice[i]=a.getString("HEADER"+(i+1));
                        Delim[i]=a.getString("DELIMITER"+(i+1));
                        putData(fName[i],choice[i],Delim[i]);//to put data in database
              catch (NumberFormatException e)
                   System.out.println("Number of files are invalid");
    hope this method would be fine ....again thanks for the advice :) :)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Using .properties file in web dynpro

    Hi,
    I am having a requirement. I have to create a .properties file and I have to use it in my web dynpro application. How can I do that? Any help...
    Thanks & Regards,
    Raj

    Hi,
    Go to the navigator view...select src\Components\<ComponentName> and create create a .properties file.
    You can read the  configuration file in your webdynpro app as follows
    IWDConfiguration configuration =
          WDConfiguration.getConfigurationByName(
            wdComponentAPI.getDeployableObjectPart(),
            "<<>>");
    http://help.sap.com/saphelp_nw04/helpdata/en/b8/aa343e32ff1033e10000000a114084/frameset.htm
    Regards, Anilkumar
    Message was edited by:
            Anilkumar Vippagunta

  • Use properties file in Struts framework

    I develop a websit with struts, web ap is tomcat5.0, and I have a conf.properties file
    this file is different from ApplicationResource.properties, conf.properties in the /MySite/conf/ directory, not in src directory
    When I Use the conf.properties file in a Common Java Class that not extends any super class
    it will occur a FileNotFoundException exception
    How to make it
    public class Environment
         private static Properties prop = new Properties();
         private static FileInputStream in = null;
         public static String getVariable(String key)
              try
                   in = new FileInputStream(new File("\\conf\\config.properties"));
                   prop.load(in);
                   return prop.getProperty(key, null);
              catch (Exception e)
                   e.printStackTrace();
                   return null;
              finally
                   try
                        in.close();     
                   catch(Exception e)
                        e.printStackTrace();
         }

    Your class cannot find the file in the location tht u have given. The path (\\conf\\config.properties) is relative to the location where your source (Environment class) is kept.
    Try to hard code the path & see if your source can find the prop file ...

  • How use class file in jsp(very urgent)

    i have class file called birds (birds is actually a xslt file transformed to java class file) now this class file i have to use in my jsp file. how can i use them. if possible can any one give me sample code please very urgent
    can any one help me

    java files
    import org.w3c.dom.*;
    import javax.servlet.http.*;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.*;
    import java.io.*;
    public class XmlParser
         public String XmlParser()
              try
    String strXML= "employee.xml";
                   String xslFile = "employeeId.xsl";
                   TransformerFactory tFactory = TransformerFactory.newInstance();
                   StreamResult theTransformationResult = new StreamResult( new ByteArrayOutputStream() );
                   Transformer transformer = tFactory.newTransformer(new StreamSource(xslFile));
                   transformer.transform(new StreamSource(new StringReader(strXML)), theTransformationResult);
                   String output = theTransformationResult.getOutputStream().toString()
              catch(Exception e)
                   System.out.println(" ***** XmlParser.XmlParser ERROR ***** " + e);
    return output;
    using class files in jsp
    <%@ page import="com.qqqq.aaaa.XmlParser"%>
    <%
         XmlParser xmlParser          =     new XmlParser();
    out.println(xmlParser.XmlParser());
    %>
    i think it will help you.

  • Use properties file out of EAR

    HI All,
    Generally we create an EAR file with all the property files embedded in it. Here the problem is as and when we change the property files we need to build a new ear file and redeploy to J2EE stack.
    Is there any way that this properties file is out of EAR application and changes done to the property file reflects in EAR? So that, no need to redeploy the application again and again. Means dynamic reflecting of property changes to already deployed EAR application. How it can be done?
    Actually this is our client requirement also...
    Hope am clear.
    Regards,
    Satish.

    Hi,
    There are ways to achieve this.
    I guess you can try following.
    You can define properties file in another project (like java project) and then include that project as a reference in your EAR application.
    Ashutosh

  • When to use properties file

    On navigating into any web application there wil be some .proeprties file (build.proeprties, applicationResources.properties etc..) and some .xml files(web.xml, struts-config.xml). Why .properties file why not all in XML ??

    The question should be: why XML and why not a properties file? XML is lots of overhead for simple tasks.

  • ECATT - How use external file/new variant for input data

    Good day,
    I want to use an eCATT created by someone else for another request. I want to be able to specify my new input data based on the new request WITHOUT generating a new Transport. Same thing as I'm doing for the CATT ... the CATT is transported but only the input data change depending on the request without generating any transport.
    How I build my new input file and how to use it? I tried to download my variant but the only possible format is XML and it's very hard to build a new file based on my request.
    Thanks for your help.
    Simon

    Hi,
    Can you tell me how you are generating the xml file. My guess is you are downloading the Test Script/ Test Configuration. In that case it creates an xml file.
    As mentioned by Ajay, In Test Configurator / Test Data -  you can create the internal variant first, i.e assuming you have already created parameters.. On the top, you have a download button "Download Variant". This creates a .txt file. You can open the file in excell and edit it.
    For the next test, you can select external variant and give the modified file path name.
    Let me know if this helps.
    Regards
    Phanidhar

  • How use pdf files

    Hi;
    I have the following process : I receive via FTP of the pdf files which are stored on a directory of my server (Tomcat + JOnas). This directory is outwards of the deployment directory of JOnas (work directory) and the pdf files are not inside of war file but uploaded directly on the directory.
    I must realized a JSP which display to user these pdf files. So my question how implemented this JSP in using external directory ?
    regards;

    Don't write a JSP to do that. You will find it almost impossible to keep extra whitespace from being sent to the client along with the PDF, and that will make the PDF unusable at the client.
    Instead write a servlet that reads from the external directory and copies the file to the response. You'll have to use (I think) application/pdf as the content type, and there are sometimes other browser-related problems with PDFs.

  • How Use "Bin" files net_oepe111130_wls1032_linux32.bin in LINUX

    hello DBA's
    I've downloaded the Weblogic and Fusion Middleware but they are in format ".bin"
    And this is suposse to setup in Lunux?
    Any Ideas whet to do with this?
    thxs
    Bests
    Carlos

    okKarol wrote:
    hello DBA's
    I've downloaded the Weblogic and Fusion Middleware but they are in format ".bin"
    And this is suposse to setup in Lunux?
    Any Ideas whet to do with this?Ensure the .bin file is executable and your Linux environment has access to the net. The bin will run a network-based install.
    These .bin files are usually self-extracting, and a brief description of this is at http://www.cyberciti.biz/faq/howto-unix-command-run-execute-bin-files-in-linux/ (which can be found using http://lmgtfy.com/?q=linux+.bin+files)
    There are forums that deal specifically in installing WebLogic Server, and these forums are available by going to the "Forum Home" link at the top of the page and scrolling down. Curious - why are you asking DBAs who deal primarily with Oracle Database Server and not middleware?

  • How to read sql from properties file in database control

    Hey Guys,
    I want to know that how a properties file can be used in bea built-in database control to read SQL.
    Any help would be greatly appreciated.
    Thanks,
    Deepak Kumar
    Qwest, India

    hi
    ok i tried it like its written in the tutorial...i do it like this:
    ClassLoader cl = ResourceAnchor.class.getClassLoader();
    props.load( cl.getResourceAsStream(pathname));
    -> tha pathname is dvd.properties
    and there always appears a NullPointerException: error reading properties file: java.lang.NullPointerException
    -angela

  • Using property files into an EAR Project? How?

    Hi there,
    I'm pretty new to j2ee development, so i hope i'm not asking a silly question.
    So what I have done / wanna do:
    - I created a ejb module project with several ejbs and several java classes in it
    - I created an ear application project to deploy the ejb module project
    - I am succesfully deploying my ear on my j2ee server
    So after all, I want to load different properties of some java classes through properties files (*.properties). How do I do that in this situation? Is there a way to use properties files altough the whole ejb project (containing the properties files) is packed into one file (the ear file)?
    I hope someone can help me an I'm pleased for every message
    Thank you all.
    Regards
    Daniel

    poissble with:
    getResourceAsStream(String)
    Regards

Maybe you are looking for

  • HT2534 Are we no longer able to create accounts without a credit card?

    I saw the instruction of how to create an account without a credit card on the support website, but I can't create my account doesn't matter whether I use my laptop or my ipad. Why? why?? Everytime I choose "none" as an option for credit card, the sy

  • Idoc to FlatFile and Flatfile to  Mail

    Hi all, I want to convert an Idoc into a FlatFile - this is no problem. But when the FlatFile is created I want to send the FlatFile via EMail as an attachment. How do I do this using Mail-Adapter ? I also thought to use an Unix Command to send the E

  • Opening ports 25 and 110?

    After a temporary switch to Verizon wireless internet connection and then back to my usual satellite internet, I can no longer send and receive mail on my Mac Pro (v 10.5). All my mail preferences look to be correct. Called my webhost and tech suppor

  • Howto define uiXML-create.uix using intersection entities and choicelists

    hi i have 3 tables: - DRIVERS: primary key dbsequence ID, attributes LASTNAME ... - RACES: primary key dbsequence ID, attributes NAME ... - RACEDRIVERS: primary key (DRIVERS_ID, RACES_ID), no attributes using the bc4j-wizards i have created the corre

  • Where I can download iTunes 10.6.3?

    my Ipod have ah new software and in iTunes , say that i need ah de las version in iTunes , where i can download iTunes 10.6.3