(Urgent) How to read file properties with virtual path?

I have the data.properties file, and write a servlet file to read properties from this properties file. But I get a problem, that is: I CANNOT USE VIRTUAL PATH!
How can I solve?
My Application Directory is,
WEB-INF
classes
loadProperties.class
data.properties
More Question,
I can use Context in Web.xml to assign values to parameters. But its will be shown. How can I hide value with a properties file?

This is not working.
I am using Tomcat 4.0.6, for my JSP application I am trying to read ini.properties file from \webapps\myapp\WEB-INF\classes\common\
directory through java bean.
System.getProperty("user.dir")
is giving <tomcat-home>\bin directory.
unless I hard code the path this way, I could couldn't read the ini file.
Properties props = new Properties();
String strIniFilePath = <webappPath> + "\\WEB-INF\\Classes\\Offenders\\Common\\";
props.load( new FileInputStream(strPropsFile));

Similar Messages

  • [Urgent] How to read files from different directories?

    I am new to Java Programming, I would like to know how to read files from directories other than the current one? (example as follows)
    ProjectDirectory
    |--MainDirectory
    |--MainProgram.java
    |--SupplementDirectory
    |--SupplementProgram.java
    |--Pictures
    |--Image.gif
    What should I write in the MainProgram.java so that I can use the supplementProgram.java from MainProgram and read the Image.gif file from the MainProgram.java?
    Thanks

    Run through the I/O tutorial here. It should get you up to speed on this sort of thing...

  • How to read the properties file available in Server File structure in webdy

    hi all,
    I have developed one webdynpro application. In this application i need to access mdm server to continue. For getting the connection i need to pass the IP addresses.
    Can i have code  how to read the properties file which is residing in the server file. with out included along with the application. keeping some where in the file structure in the server. I want to read that properties file by  maintain the iP addresses and users in  properties file based on the key i want to read like below.
    servername="abcServer"
    username="john"
    password="test123"
    Please send me the code how to read this properties file from the file structure and how to read this values by key  in webdynpro application
    Regards
    Vijay

    Hi Vijay,
    You can try this piece of code too:
    Properties props = new Properties();
    //try retrieve data from file
    //catch exception in case properties file does not exist
    try {
             props.load(new FileInputStream("c:\property\Test.properties")); //File location
             String serverName = props.getProperty("servername"); //Similarly, you can access the other properties
             if(serverName==null)
               //....do appropriate handling
         }     catch(IOException e)
                   e.printStackTrace();
    Regards,
    Alka.

  • How to read from properties file

    Hi,
    I am using JSR 168.
    while creating a new portlet, a folder gets created with the name as "portlet". Under which is resource package and <PortletName>Bundle.java.
    pls tell me how to read from .properties file.
    waiting eagerly for some reply
    Thanks & Regards,
    HP
    Edited by: user9003827 on Apr 13, 2010 3:42 AM

    I think i have mixed it up :)
    I have looked at it again and believe you are using regular JSP portlets.
    Can you tell what you want to achieve by reading .properties file. Are you meaning the preferences of the portlet or what exactly are you trying to do?
    Reading propertie files is easy:
    // Read properties file.
    Properties properties = new Properties();
    try {
        properties.load(new FileInputStream("filename.properties"));
        String myKey = properties.getProperty("yourKey");
    } catch (IOException e) {
    }Edited by: Yannick.O on 13-Apr-2010 05:52

  • How to do file validation with ODI 10.1.3.5

    Hi Team,
    Please help me, how to handle file validation with ODI?
    My source is files.
    Requirement:
    With ODI i have to do the file validation and file data loading successfully. Once it is successfully done then i have to move the particular file and move to different directory.
    Any internal tool is there in ODI package to watch the file.
    Regards,
    Suresh

    Hi Suresh,
    You can do your file loading and validation in an ODI interface.
    Once you are done with the interface, add it to a package, you can set up subsequent steps in the package to move the file to another location using the built in ODI file utilities in the package.
    Terrence.

  • How to read waveset.properties

    Hi group
    Please let me know how to read waveset.properties file for finding SOURCES.RESOURCENAME.HOSTS where I ll have different host name to get connected to Authoritative Resource.
    Please Help me.
    Thanks in advance.
    Regards
    Gajendra Nagapurkar

    Hi,
    You can invoke static java method getProperty on class com.waveset.util.WavesetProperties.
    Argument is name of your property.

  • How  to integrate File Server with Portal??

    Hi all,
    can any one tell me that how interegate the File Server With Portal Server??
    In my portal server under home tab i have sub tab (second level navigation) of File server.Whe i click this tab it throws an syntax error
    ie
    System Error
    An exception occurred during the program execution. Below you will find technical information pertaining to this exception that you might want to forward to your system administrator.
    Exception Class  :: class com.sapportals.wcm.repository.NotSupportedException
    Exception Message  :: Not Implemented
    thease are the steps that i have taken
    >created HTTP System..
    >created WebDAV Repository.
    >Created Cache.
    >Created KM WebDAV System.
    >Created Iview and in iview i have to specify the <b>Path to Initially Displayed Folder</b>
    i have specified the folder of file server that i want to display..
    but i get the same syntax error ..
    infact i dint get that folder in KM.
    But when i specify the folder that is present in KM its Work fine..
    Now the Scnerio According to me is that File server is not integrated properly
    if it would be integrated properly i would be able to see the folder of File server in  KM...
    am i correct ??
    please Guide me to integrated the File Server Properly??
    Points will be given for any help..
    Regards
    Vinit

    Hi Vinit,
    if you want some Windows File Server integrated into Portal, please do not use a WebDAV Repository, but use the File System Repository instead. Therefore you need to configure the according Repository Manager. Please refer to this documentation:
    <a href="http://help.sap.com/saphelp_nw70/helpdata/en/ed/b334ea02a2704388d1d2fc3e4298ad/frameset.htm">Integrating Documents from a Windows System into KM</a>
    HTH,
    Carsten

  • How to use File Adapter with hierarchial Structure?

    Hi,
    How to use File Adapter with hierarchial Structure like..
    Data:
    --Header Details:
    Line Item Details:
    Data
    Bcoz I am getting a Flatfile in a hierarchial way as shown below.
    Header Details :1
    Line Item a
    Line Item b
    Header Details :2
    Line Item c
    Line Item d
    Kishore

    Hey Kishore,
    In order to create a structure you need to use the file with convertion mode on the sending communication channel of the file adapter.
    check the link for the needed configuration paramters.
    If the structure is more complexed you can use the Contetnt master(CM) from itemfield which allows to ceate XML file from complex flat files and more.
    <a href="http://help.sap.com/saphelp_erp2005/helpdata/en/0d/5ab43b274a960de10000000a114084/frameset.htm">File sender adapter</a>
    If you have any question i'll be more than happy to assist.
    Nimrod Gisis

  • How can I file share with another person if both of us are using Mac operating systems?  Do we need to use a third party file sharing system or does apple have this capability?

    How can I file share with another personif both of us are using Mac operating systems (one of us using a Mac laptop and the other using iMac).  Our intention is to have a working document that can be changed by both parties over time and both parties will have visibility to the others changes.

    Use SugarSync

  • How to read a properties file

    hi
    I have a properties file.
    I am using load method to load the properties file but i have encountered a problem here.
    the properties file has space like
    FIRST PROP=xyz
    SECOND PROP=abc
    my question is how to read the file
    thank u

    Either format it properly--I think a \ before the space will work--or write your own method to use in place of Properties.load.
    (Or, I suppose, you could inject your own InputStram that translates the lines on the fly to include the \, but that would probably be more trouble than it's worth.)

  • How to read file at server? URGENT

    hi,
    I got stucked to read a file which is at the server, i used this code :
    java.io.FileInputStream fis;
    String ipaddr="";
    int ch;
    try
         fis=new java.io.FileInputStream("server.ini");
         while((ch=fis.read())!=-1)
              ipaddr=ipaddr+(char)ch;
         ipaddr=ipaddr.trim();
         System.out.println(ipaddr);
    }catch(Exception e){System.out.println(e);}
    I'm getting a FileNotFound exception, where i went wrong.

    Hello hikiran.
    The server.ini file should reside in your application working directory. If it's not there, then the JVM won't find it. Otherwise you could specify an absolute path to the file, but your application will be less portable. Another choice you have is to define an environment variable which tells your app where the server.ini file resides, with the command
      java -Dmyapp.ServerIni=C\SomeFolder\server.ini myappThen you retrieve the pathname with:
       String path = System.getProperty("myapp.ServerIni");This way your app does not depend on the filesystem on which it's been installed to, because changing the command line that starts your app will be enough to have it working.
    Note: if you have to read a text file consider using the java.io.BufferedReader class which lets you to get rid of the different text file formats problems you find when you move to a unix like platform (newline characters are different).

  • How to Read file name which we are dealing with ODI File tool

    Hi,
    We are using ODi10g version and we have requirement to move file from one place to another place. We are using ODIFileMove utility but we also want to read file name.
    Any help.
    Thanks in Advance.

    You can accomplish this with a fairly simple Jython script.  Use the os.listdir(<directory>) command to get the name of files in a given directory. 
    You can then (still in the Jython script) loop through the files and move them to a desired location (bypassing the OdiFileMove tool) OR use the Jython script to write the file names to a SQL table.  Then, use an ODI procedure to loop through the newly inserted records and store the file name in an ODI variable that you can then use in your OdiFileMove tool etc.
    I often refer to this blog entry from Gurcan Orhan as a starting point for this kind of task: Loading multiple files with ODI | Gurcan Orhan&amp;#039;s Oracle Data Integrator Blog

  • How to change File Properties Creator

    I'm using PSE 7.0 Organizer. When I change the date/time of my files, PSE assigns 'Adobe Photoshop Elements 7.0' to the Creator in the File Properties.
    How can I change this to a string of my chosing, such as ME. I'm am using right-click file > Adjust Date & Time of Selected Items... to set the date/time on images that I'm scanning from slides.When these images are scanned, there is no Exif data in the scanned file until I do this action. So this is the only way I know to get these to be sorted in the correct Date taken order.
    Thanks,
    John

    You can't change the "Creator" tag under "File properties" in PSE7.
    Anyhow the "Creator" Tag here represent the Application through which edition has been done on the image, it does not represent the Author.
    If you want to add your name as a author to a image, you can do the same by opening the image with Photoshop Elements Editor and follow these steps:
    1. Click on "File" menu and select "File Info".
    2. Now in the "File Info" dialogue box, Select the Tab "IPTC" and enter your name against the Coloumn "Creator" or you can do the same by selecting tab "Description" and entering your name against the Column "Author".
    3. Now Save the file.
    Now open the same file in organizer again and look for the metadata properties of the image, Click on Radio button "View: Complete" to view complete metadat of the image. Now You can see your name against the "Author".
    Hope It must have resolved your query.

  • Do anybody know how to read file...

    Hello,
    I have a problem with reading config file. Do anybody know how to read config file from the same dir as class.
    Now the situation is like:
    filePath I hardcoded like:
    fileName = "C:\\apache-tomcat-5.5.17\\webapps\\ROOT\\WEB-INF\\classes\\config.sales";
    Is it possibility to read config file wich is used by java classes (in prj) from the same dir as classes are?
    Thanks in advance.

    If the file is in the class path you should be able to access it using the Class.getResourceAsStream method. It is the same concept as loading a properties file:
    http://www.javaworld.com/javaqa/2003-08/01-qa-0808-property_p.html

  • How to read file from server if I have a logical file path?

    Hi guys,
    I'm having a pretty "on the run" question,
    My program is currently reading a file from server using "open dataset" with file path like this (just example)
    /usr/interface/abc/bcd/testfile.dat
    Now I got a requirement to make it more consistent to read files, instead of reading that physical file name, I should read the files from a specific folder using logical path.
    So I go to T code "FILE" and created a logical path called ZABC_FILE_PATH, unix compatible, with physical path is (for example),
    /usr/interface/<sysid>/<client>/<filename>
    My question is, can I still use open dataset statement to read this? if yes, how do I do that? If no, there should be alternative way, please let me know what you think. Thanks,

    Thanks all, I figured it out.
    ONe thing is that typo double quote
    The other thing is the importing part, I need the full file path.
    CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
      EXPORTING
        CLIENT                           = SY-MANDT
        logical_path                     = 'ZABC_MY_LOGICAL_FILE_PATH'
    *   OPERATING_SYSTEM                 = SY-OPSYS
    *   PARAMETER_1                      = ' '
    *   PARAMETER_2                      = ' '
    *   PARAMETER_3                      = ' '
    *   USE_BUFFER                       = ' '
        file_name                        =  v_1
    *   USE_PRESENTATION_SERVER          = ' '
    *   ELEMINATE_BLANKS                 = 'X'
      IMPORTING
        FILE_NAME_WITH_PATH              = v_what_I_need
    * EXCEPTIONS
    *   PATH_NOT_FOUND                   = 1
    *   MISSING_PARAMETER                = 2
    *   OPERATING_SYSTEM_NOT_FOUND       = 3
    *   FILE_SYSTEM_NOT_FOUND            = 4
    *   OTHERS                           = 5
    I really appreciate your contributions, thanks again!

Maybe you are looking for