How to mention a  Relative path in a java file

How to mention the relative path of the file in fileinputstream?
The directory structure is as follows,Inside the **model** folder i have a java file called GetContents.java
I need to refer the input.xls file inside the template folder in GetContents.java.file.
I tried new FileInputStream("..\\..\\..\\template\\DevContentsTemplate.xls") cos the GetContents.class file will be inside webcontent\web-inf\classes\model\GetContents.class and I thought if i use the above relative path , it should refer webcontent\web-inf\template\input.xls
But it throws a file not found exception.
ContentValidation
- src
-action
-model
          -bean
          -form
          -utils
-WebContent
               -WEB-INF
                    -classes
                    -action
               -model
                         -bean
                         -form
                         -utils
                    -lib
               -template
                         -input.xls
Kindly help.
Thanks.

morshed_nsu wrote:
if so then for one ../ you will reach classes folder. for another you will reach the folder containing src, classes, templates etc.
So you do not need 3 escapes.I posted that same answer 7 hours before you did! What part of your answer is any additional help compared to mine? It's fine to give someone another answer, but there's not much point in giving the SAME answer 7 hours later. If it were a few seconds or a few minutes later, I would excuse you for having tried to post at the same time. But, 7 hours?! Please read the existing answers next time, not just the original post.

Similar Messages

  • Can any one suggest me how can I use relative path inside SSIS pacakge to access config file ?

    Can any one suggest me how can I use relative path inside SSIS pacakge to access config file ? Please help me as its urgent.THanks for your help in advance.

    Hi Jay,
    SSIS can only recognize the absolute path of a XML Configuration file, the relative path is not supported. Furthermore, if the XML Configuration file is already generated, we can use the Environment variable package configuration type instead so that
    SSIS runtime automatically looks for the configuration file from the path defined in the environment variable. This is convenient when we need to deploy a package to different environment. We only need to define the environment variable for package configurations
    once on each server, and then the variable can be used by all the packages on this server.
    Regards,
    Mike Yin
    TechNet Community Support

  • How to give a relative path from a button in the master page header?

    so I have this code in the header of my Master page in RoboHelp:
    <input type="image" value="View graphics legend"
    onclick="window.location.href='Graphics_legend.htm'"
    src="Images\graphic legend.png" name="image1"
    title="View graphics legend" style="width: 118px; height: 21px;" />
    i need to call the 'Graphics_legend.htm' file which is sitting in the root folder. When i try this it works fine for the html file which are in the root folder as well, but anything with is in a sub directory , the button stops working.
    It might be just to add a realtive path ,but i am failing to understand how to make a relative path for 'Graphics_legend.htm' ,.. ?

    Hi there
    Relative paths are relatively simple once you get the hang of them.
    For example, if you want to refer to something that is one folder above where you are, you prefix things with ../
    The ../ is HTML shorthand meaning one folder level above where I am. If you wish to go two folder levels up, ../../
    If you need to drop into a folder that is at the same level as where you are, ../FolderName
    From what you have written it would seem that RoboHelp isn't seeing your code and properly calculating the path. That's really not too surprising because you are using the Button element.
    If you are using CSS and linking to a style sheet you likely have a simple way to calculate what the relative path should be. Just examine the source code of the topic and note what prefixes the CSS file name. Assuming your CSS is in the project root (and it should be) then you could use the same prefix.
    Hopefully this helps... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7, 8 or 9 within the day!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • How can I write relative path in File, ImageIcon objects

    I have downloaded examples from
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/index.html
    but for some reason images are invisible until I write absolute paths?(I use windows) How can I write relative path in File, ImageIcon objects?

    Hello;
    I've found a lot of complaints about this through the Forte forum as well as on Dejanews. I'm just curious as to whether any of you ended up finding a solution to this problem.
    There was one posting about setting up the subdirectory as a URL rather than a String and then using that as the source of the ImageIcon ... but this didn't work for me.
    Any help whatsoever would be appreciated.
    Thanks!

  • How to enter a relative path of flv

    We have a project with flv video embedded in one of the slides.  It works perfectly fine when we use absolute path to insert Flash video, e.g. (D:\Videolessons\communication\101.flv).  Now the client wants to deploy it in a media server and asks us to provide a relative path of the Flash video.  We tried something as follows:
    /communication/101.flv
    communication/101.flv
    /Videolessons/communications/101.flv
    Videolessons/communications/101.flv
    We put flv file in the "communication" folder. We then published the CP project to that folder as well.
    Unfortunately the published file doesn't contain the flash video any more.   The first two settings (/communication/101.flv and communication/101.flv) does not give error message, and the last two settings actually prompted the message that the Flash video cannot be loaded.
    What is the correct way of entering the relative path of the FLV file?  Thanks for your help.

    Skylineblue,
    Video is treated differently than other assets Captivate.  The path to the .flv file is NOT a runtime setting... which is really confusing.  The path that is entered for the .flv file should be relative to the SAVED PROJECT.  So, if your Captivate project file is located at D:\Videolessons\MyFile.cp and you have flash video files in D:\Videolessons\communication\101.flv, you could enter a relative reference like: "communication\101.flv"
    When you go to PUBLISH your captivate project, these .flv files will be MOVED to the publishing location.  So if you're publishing to C:\Publish, your .flv files would end up at C:\Publish\communication\101.flv.  FYI... after you publish, your video files will be moved... not copied, which can be a pain if you have to re-publish.
    HTH,
    Jim Leichliter

  • How can I see the path from the preview file (*.prel) to my video files ?

    Because a lack of hard disk space I have moved my video files to another drive and therefore unfortunately destroyed the relative connection to the preview file (*.prel).
    Therefore the videos are not to be seen in the preview file any more.
    How can I get information about the relative path between the preview file and the place for the original video files so I can get those back in the original position ?
    or:
    It may be possible to change the path for every clip in my preview file - but how ?
    I can read answers in English, German or Danish.

    hansk
    What version of Premiere Elements on what computer operating system?
    Generalizing for now...
    If you know where the files are by actually seeing them in their hard drive save location and you are getting "Where is the file ______?" messages, then you use those
    messages to reconnect the source media to the project. Are you getting those messages and have you tried for the reconnects that way?
    If edits are involved in the files that have become disconnected to the project, you can also consider the program's Replace Footage feature.
    ATR Premiere Elements Troubleshooting: PE11: Replace Footage
    Typically either of these ways is one at a time reconnects. With the "Where is the file _____?" message way sometimes you get lucky (depends on the circumstances) and more
    than one file at a time might reconnect.
    Please review and consider. Any questions or need clarification, please ask.
    ATR

  • How to view the change immediately after a java file is modified without restarting server or redeploy?

              Hi All,
              How to view the change immediately after a java file that is used in jsp is modified
              without restarting server or redeploy?
              Moreover, it is better to keep the original session.
              Any suggestion is appreciated.
              Kammau
              

              Hi,
              In order to have a new version of a java class, the current classloader must be
              deleted and a new one created. This is what redeployment does. I believe that
              this is more of an issue with Sun's implementation of classloaders. You could
              ask BEA support (719.232.7878) and see if they have any plans to periodically
              check jar files to see if java class file timestamps and destroy and re-create
              classloaders on the fly.
              1) You will still have to accept the performance hit of destroying classloaders
              and creating new ones. There isn't any way around that.
              2) I would think you would want to have more explicit control in production and
              integration anyway.
              You can redeploy applications from the command line (script) file not just the
              console.
              Hope this helps,
              pat
              "Kammau" <[email protected]> wrote:
              >
              >Hi All,
              >How to view the change immediately after a java file that is used in
              >jsp is modified
              >without restarting server or redeploy?
              >Moreover, it is better to keep the original session.
              >Any suggestion is appreciated.
              >
              >Kammau
              

  • How to create a relative path for Flash video on a CDROM

    Hello - I need to distribute a web site to a client on a
    cross-platform Hybrid CDROM so that they can edit and make
    adjustments. This website also includes 2 flash videos that need to
    be included on the CDROM.
    My problem is this: I encoded the video in the Flash Encoder
    app and brought them into the main Flash app for conversion into
    swf files. I also used the media controller parameter to add a
    control skin to the movies. I now have 2 swf files associated with
    the flv video file, and I understand that all 3 of these must stay
    together for the video to work properly. The video plays correctly
    along with the controller skin on my Mac however only the
    controller shows up but no video on the CDROM. I believe that this
    has something to do with absolute vs. relative file paths for the
    video flv file to the swf controller file.
    I do not know how to change this path - I know "where" to
    change it within the controller parameter options box but do not
    know what syntax exactly to place here. How do you specify a
    relative path here? When I try to do it I get an error saying that
    the flv file cannot be found.
    I am trying to use the following syntax: /video/welding.flv
    where video is the name of the folder and welding is the name of
    the file. I have done numerous Google searches on this subject and
    stil cannot find an answer, so any help is appreciated.

    OK - I assigned the FLVPlayback component the instance name
    of videoPlayer to keep it simple. And I copied the above code into
    an Actions - Frame on Frame 1. FYI - The name of the video has been
    changed from welding to Timet Sponge.
    Now I get the following error messages:
    **Error** Scene 1, Layer 'Layer 1', Frame 1, Line 1: 1119:
    Access of possibly undefined property contentPath through a
    reference with static type fl.video:FLVPlayback.
    videoPlayer.contentPath = "";
    **Error** Scene 1, Layer 'Layer 1', Frame 1, Line 2: 1120:
    Access of undefined property _global.
    _global.videoURI = "video/Timet Sponge.flv";
    **Error** Scene 1, Layer 'Layer 1', Frame 1, Line 3: 1120:
    Access of undefined property _global.
    videoPlayer.contentPath = _global.videoURI;
    **Error** Scene 1, Layer 'Layer 1', Frame 1, Line 3: 1119:
    Access of possibly undefined property contentPath through a
    reference with static type fl.video:FLVPlayback.
    videoPlayer.contentPath = _global.videoURI;
    **Error** Scene 1, Layer 'Layer 1', Frame 1, Line 1: 1119:
    Access of possibly undefined property contentPath through a
    reference with static type fl.video:FLVPlayback.
    videoPlayer.contentPath = "";
    **Error** Scene 1, Layer 'Layer 1', Frame 1, Line 2: 1120:
    Access of undefined property _global.
    _global.videoURI = "video/Timet Sponge.flv";
    **Error** Scene 1, Layer 'Layer 1', Frame 1, Line 3: 1120:
    Access of undefined property _global.
    videoPlayer.contentPath = _global.videoURI;
    **Error** Scene 1, Layer 'Layer 1', Frame 1, Line 3: 1119:
    Access of possibly undefined property contentPath through a
    reference with static type fl.video:FLVPlayback.
    videoPlayer.contentPath = _global.videoURI;
    Total ActionScript Errors: 4, Reported Errors: 4

  • How to load a .properties file by giving relative path in a JSP file.

    Hey guys,
    I'm trying to load a .properties file in a JSP using relative path...
    It is not taking the properties file..
    What is the problem...?
    Any solution..?
    Thanks a lot.

    Yes I tried that also.
    Your path was something like this ?
    http://localhost:8080/Database/a.properties ?
    Whether this path will change after client installation ? if no then what's the problem ?
    For client side installation how you are going to set your conf directory for your application ?
    You are not going to give client installation page ?which will have all the values to be set like conf path. database,user name(s),log folder,temp folder etc ? Why you are keeping everything on server ?
    Check if this is useful,
    String context = request.getContextPath();
    String rmtAdd = request.getRemoteAddr();
    String host = request.getRemoteHost();
    out.println("http://"+rmtAdd+context+"<BR>");
    out.println("http://"+host+context);
    "http://"+rmtAdd+context
    Edited by: kanad on Jan 12, 2008 1:29 PM

  • How to store a relative path in a global variable

    Hi,
    I'm using Teststand 2013 and Labview 2013
    Is it possible to define a relative path for a global variable in the Teststand? Ex. "..\vector1.hws"
    Or I should use the Labview functions to solve this issue?
    Thanks,
    Solved!
    Go to Solution.

    Paths are so much easier to manipulate in LabVIEW.  So you could store the relative path as a string and then use LabVIEW to make the absolute path.
    I typically store a folder in a global variable and then I can just concatinate the strings to build the absolute path.  For example:
    FileGlobals.Folder = "C:\\foo\\bar\\",
    Locals.Path = FileGlobals.Folder + "blah.txt"
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Relative path for servlet property file.

    I have the following java file. When I use the absolute path for the configFile, it works. I would like to know how I could use it as relative path as in installation, the name of the directory could change.
    How do I fix the problem? Thank you.
    ---------------------- LoadProperties.java ----------------
    import java.util.*;
    import java.io.*;
    public class LoadProperties {
    private String driver="";
    private String dbURL="";
    private String login="";
    private String password="";
    static public void main(String[] args) {
    LoadProperties lp = new LoadProperties();
    } // main
    public LoadProperties() {
    //String configFile = "C:/1LMS/web-app/WEB-INF/config/db.properties";
    String configFile = getClass().getResource("config/db.properties").toString(); <--- This line could not find the db.properties file.
    Properties Prop = new Properties();
    try {
    FileInputStream configStream = new FileInputStream(configFile);
    Prop.load(configStream);
    configStream.close();
    } catch(IOException e) {
              System.out.println("Error: Cannot laod configuration file ");
    driver =Prop.getProperty("driver");
         dbURL = Prop.getProperty("dbURL");
         login = Prop.getProperty("login");
    password = Prop.getProperty("password");
    printResult();
    } //Load Property
    private void printResult() {
         System.out.println("Driver = " + driver);
         System.out.println("dbURL = " + dbURL);
         System.out.println("Login = " + login);
    System.out.println("PSWD = " + password);
    } // class

    hi there,
    had the same problem... you need to use following API:
    http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)
    In your case something like that:
    // get the servlet context
    ServletContext context = getServletContext();
    // directory name where the file is located
    String realPath = context.getRealPath("/config");
    // get real path to your file
    String propertyPath = real+"filename.txt";
    hope that helps!!
    minu

  • How can i set a path for my deployment files in weblogic server 10.3

    Hi
    How can i set the path for my WAR ,JAR files while deploying.i am using the wls10.3 version.
    is there any scripts for this ,please provide me.
    my Application is ADF 11g application.

    By "path", I assume you mean "classpath".
    The simplest way is simply to include the jars you need inside the web application or web module's WEB-INF/lib directory, EJB module's META-INF/lib directory, or EAR lib directory.
    If that's not practical, if you use NodeManager to start your servers, you can go to the "Server Start" tab in the server definition in the WebLogic console and edit the "Classpath" field, which defaults to no value. You can specify a classpath value there. Note that if you specify a value there, it REPLACES the default classpath for the server, it doesn't add to it. If you need to just add to it (a much more likely scenario), if the value references the value "$CLASSPATH" in it, that will reference the original classpath value that the server would have had.
    So, for instance, if you wanted to include the MQ jars in the server classpath, you could set a value like this:
    /usr/java/mq/lib/mq.jar:/usr/java/mq/lib/mqstuff.jar:$CLASSPATH

  • How to get the full path name of a file

    Hey everybody, I'm new here and in Java.
    so I will explain my question by giving an example:
    I want to send file from the Desktop by the "Send to" on the popup menu to my program.
    I want to know how can I read the full path name and the file name, and show it on my text box.
    Thanx alot

    If this is a client side application then I'd say look into drag-n-drop tutorials.
    i.e. drag file to your application, action listener fires, create File object giving you full name and path of users action.
    If this is a web application then look into the "multipart/form-data" content type specifications on how to upload files.
    i.e. user specifies file from <input type='file' ... /> type, submits, servlet receives data and recreates file locally on application server side.
    If you are thinking that all you need to send a file to a program is the full path and name in a textbox its a little bit more complicated then that.
    Good luck, hope that helps!

  • How to get the real path of the xml file

    I have a java application
    following is the package structure
    com>>gts>>xml
    having file---------> MyXML.xml
    com>>gts>>java
    having java program to read the file
    Problem is if I use File file = new File("..\\xml\\MyXML.xml");
    java.io.FileNotFoundException: E:\LEARNING_WORK_SPACE\JavaXml\..\xml\MyXml.xml (The system cannot find the path specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(Unknown Source)
         at java.io.FileInputStream.<init>(Unknown Source)
         at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
    How do I get the real path of the xml file.
    Edited by: shashiwagh on Jan 29, 2010 11:46 AM

    Hi,
    if your XML file is inside a package you can easily get it from the classloader.
    Note that your application maybe packaged inside a jar so it is not safe to use java.io.File for this purpose.
    You have an xml file in :
    com/gts/xml/MyXML.xml
    in a class of the same module (that will packaged in the same jar) for example com.gts.java.XmlLoader :
    // To get the stream :
    InputStream is = this.getClass().getResourceAsStream("/com/gts/xml/MyXML.xml");
    // Or the URL :
    URL xml = this.getClass().getResource("/com/gts/xml/MyXML.xml");Hope it helps.

  • How can I get the path of an existing file????

    Hi.
    I'm a newbie in Jsp development, so this question may appear trivial.
    How can I get the path into a String of an exixting file ..like ...
    String thepath = path_of("my file.txt");
    Thanks for your help.

    Try
    application.getRealPath("myFile.txt")

Maybe you are looking for

  • Open and closing balances std report

    Dear All, please suggest me open and closing balances std report and can i suggest my user below t.code for viewing open and closing balnces for India scenarion T.code:J3RFLVMOBVED Regards Gopal.S

  • How to transfer old Voice Memos back into Memos on app iPhone?

    I have just upgraded to ios 7 and it has deleted all of my old Voive Memos from my iPhone. I still have them all in my iTunes, but how can i transfer them back into the Voice Memos app on the phone? Whenever I select to import voice memos from iTunes

  • E71 - GPS and 3G

    Hello, I am considering purchasing an E71. Two questions: 1. I see that the GPS is an AGPS. Does that mean that I have to have some cellular data transfer constantly going on or just initially while I am being located? Is it possible to use the GPS w

  • Pdf's freeze using Reader in server based Mac 10.6 or 10.5

    I support several hundred iMac's for a school district. We have a site license for Adobe CS4 (and CS3). The user's accounts are server based. The programs are installed on the local computer. If I create a local account and log into that local accoun

  • Dreamweaver CS4 and Photoshop elements 10

    Can i intergrate Photoshop elements to work with Dreamweaver cs4, Photoshop shows up on the editor button in Dreamweaver but when i try to use it it tells me it cannot find the file, even thought i no the file is there, Is there some setting i am mis