Problems Accessing Local Files

Hi,
I'm sure this has been discussed before, but I'm havign problems accessing a file on the target machine's local filesystem. I've signed all my jars and added the all-permissions tag to the jnlp file. However, my code:
ClassLoader cl = getClass().getClassLoader();
InputStream is = cl.getResourceAsStream("c:/resources/testsuite.xml");
fails to find the file "testsuite.xml".
Is this a classpath issue? I've tried to add c:/resources to the class path but with no luck.
any help would be much appreciated
Thanks

Try "file://c:/resources/testsuite.xml" instead. I
believe you are suppose to be passing in a valid URL
and what you passed in wasn't.That's wrong. Resource name should be just a path. It could be a full path started from "/" or just a relative path from given class (here better to use this.class.getResourceAsStream() method).
Better yet, since you are giving full security access
to the user's local machine you don't really need to
rely on the class loader at all. It's just a normal
file, so you could create your File object and read it
in the way you do normally. I would suggest to do not rely on File object at all because it can only be dealing with local file system and thats can't be changed in future.

Similar Messages

  • How Can I Get A Flash Movie to Access Local Files

    I have a customer that has created a Flash movie to run off a CD.  The movie is basically a set of menus with links to access local files in the same directory as the movie.  i.e. Main folder (to be root of CD) has the movie, a Documents folder with PDFs, a Movie folder with wmv and mov files, etc.
    The problem arrises when you click on a link to a file, a web browser is launched, and the browser tries to display the target file.  The movie was designed on a Windows system, and, mostly it works in a Windows environment, however, the links totally crap out on a Mac because the URLs are pc centric.
    He is a rookie flash programmer so I am trying to help him set up proper links to the files, so that the files will (hopefully) launch the proper local app and not a web browers.  i.e. if the link points to a PDF, the Adobe Reader is launched; if the link is to a mov file, then QuickTime is launched....
    Is there a way to do this?  All the tutorials I have found all seem to expect the flash movie to be running on a web server, and as such do not work when running the movie off a CD.
    Any help or suggestions would be grealy appreciated.
    A response ASAP would also be greatly appreciated as the customer needs to deliver 200 CDs of the project for a presentation tomorrow morning - I have to create the CDs...
    TIA

    Hi there,
    Maybe you would want to use swfObject, i've been using it for
    a long time now.
    http://blog.deconcept.com/swfobject/
    cheers

  • Applet access local file

    I have an applet that access local files and directory.
    I have create the applet policy file.
    When viewing with appletviewer, we can type:
    appletviewer -J-Djava.security.policy=applet.policy MainApplet.html
    However, when I want to embed the applet in a html, how can the policy file be included?
    Thx a lot.

    how can the policy file be included?Applets use the java.policy wich is located in the jre/lib/security
    (C:\Program Files\Java\jre1.5.0_04\lib\security)
    There is a java.security where you can add or change the java.policy files to be
    used
    policy.url.1=file:${java.home}/lib/security/java.policy
    After changing these files make sure the jre loads again, close all browsers
    and open the page.
    Signing applets:
    http://forum.java.sun.com/thread.jsp?forum=63&thread=524815
    second post and reply 18 for the java class file using doprivileged
    http://forum.java.sun.com/thread.jsp?forum=63&thread=409341
    4th post explaining how to set up your own policy with your own keystore
    Still problems?
    A Full trace might help us out:
    http://forum.java.sun.com/thread.jspa?threadID=656028

  • Can I access local files?

    I am writing an application using Adobe Air that will have to utilize and store media files locally on a user's computer.  My marketing team now believes that a downloadable application that will be installed on a user's computer will be a dealbreaker for some users due to the fear of a virus, so now they are suggesting that we will have better sales numbers if people just need to log into a website to use the application.  No problem, Air applications can be embedded into a website.  But can an Air application embedded in a browser still store and manipulate files on a user's computer?  Storing media files for a large number of individuals can become cost prohibitive, so rather than store them online, we would like to create a folder on a user's system to organize their files.  Is this possible with a web-embedded Air application?
    Thanks.

    AIR applications are always installed on the user's computer. You cannot run an AIR application on a website. On a web page, you can include a link to download or install an AIR application.
    AIR applications can access local files.
    Flash Player applications can also access local files, but the user first grants permission. For example, see the FileReference.load() and FileReference.save() methods (added in Flash Player 10):
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference .html

  • Reading files from local hard disk - Access Local Files Only

    Hi All,
    I have a local flash file published as 'Access Local Files Only', to allow me to read from local filesystem.
    What methods or classes can I use to read text and other files from the user's harddisk.
    This is the first time I am trying to do something like this, all help is grealy appreciated.
    Thanks
    Andy

    Hi, thanks for the responses
    I did some searching and found that the urlloader class is the right one for the job.
    'Access Local Files Only' option is provided for this very purpose I believe.
    If anyone has done something like this and have some sample code it would be awesome
    Cheers
    Andy

  • When i drag and drop an image on my site. it gives the following error. "Unable to access local files due to browser security settings. To overcome this, follo"

    I am using the firefox version 17 and when i drag and drop an image on my website. It gives me the following error.
    Unable to access local files due to browser security settings. To overcome this, follow these steps: (1) Enter "about:config" in the URL field; (2) Right click and select New->Boolean; (3) Enter "signed.applets.codebase_principal_support" (without the quotes) as a new preference name; (4) Click OK and try loading the file again. Or go to the homepage for a link to the tutorial on how to do it.
    I have completed the above steps and it is still showing the same error message. Any help would be highly appreciated.
    Thanks.

    Thanks kumars ,
    I have a specific drag and drop area on our website. This works fine for all earlier releases of Firefox after these security settings
    "(1) Enter "about:config" in the URL field; (2) Right click and select New->Boolean; (3) Enter "signed.applets.codebase_principal_support" (without the quotes) as a new preference name; (4) Click OK and try loading the file again."
    Bust these settings not work for me in Firefox 17.
    Yes the drag and drop functionality is java script based and i am not using any script blocker addons.

  • Can firefox support "file:///" format to access local files (note 3 fw slashes) this works for IE but not firefox and is the format used in the "afghan war diary" from wikileaks

    can firefox support "file:///" format to access local files (note 3 fw slashes) this works for IE but not firefox and is the format used in the "afghan war diary" from wikileaks

    See http://kb.mozillazine.org/Links_to_local_pages_do_not_work

  • Accessing local files in Safari for Windows

    I am trying to access local files, such as .doc and .pdf files. I have tried
    file://server/dir/dir/file.pdf, and various numbers of slashes, but all result in Failed to open page messages.
    Any ideas? IE can do this, Firefox won't (easily).
    Chris

    If you wish to view "local" files in any browser just drag the file icon to an empty browser window.
    The "file:///blah/blah" stuff and a URL has ended for security issues.

  • Problem accessing local interface methods

    Hi all,
    I have problems accessing local interfaces of entity beans in OC4J.
    My application consists of a session bean as a facade for two local entity beans.
    Everytime I try to execute methods on the local interfaces for the entity beans, I receive an exception: "java.lang.InternalError: Illegal removing from cache".
    When debugging the application everything seems to be fine until the method calls on the local interfaces (lookups, create methods etc OK). I can even see that the local interface method is acually executed when performing a System.out...! But the method doesn't return to the client (session bean). Instead I revieve the exception above.
    I found a similar problem on the orion mail archive (http://www.mail-archive.com/[email protected]/msg17754.html). But there they seem to have problem with removing beans. For me, removing beans works fine too.
    Any suggestions would be appreciated.
    /johan
    [email protected]

    Hi all,
    I have problems accessing local interfaces of entity beans in OC4J.
    My application consists of a session bean as a facade for two local entity beans.
    Everytime I try to execute methods on the local interfaces for the entity beans, I receive an exception: "java.lang.InternalError: Illegal removing from cache".
    When debugging the application everything seems to be fine until the method calls on the local interfaces (lookups, create methods etc OK). I can even see that the local interface method is acually executed when performing a System.out...! But the method doesn't return to the client (session bean). Instead I revieve the exception above.
    I found a similar problem on the orion mail archive (http://www.mail-archive.com/[email protected]/msg17754.html). But there they seem to have problem with removing beans. For me, removing beans works fine too.
    Any suggestions would be appreciated.
    /johan
    [email protected]

  • Problems accessing parameters, files - problems in general.

    I've been posting my problems to comp.lang.java.programmer but Google Groups is exceedingly slow to update and I've been stuck on this for nearly two whole days:
    I am developing what will be a series of web utilities for our company and our client's company. Unfortunately I am hampered by the fact that my Java is not that good having come from a C++ background.
    My current setup is Windows XP, JDK 1.3.1.07 (which is what our client is running), Tomcat 4.1 for testing on my local box.
    I've been middling around with small examples and decided to do something slightly more complex. What I am trying to do is access a file that is described in web.xml as a parameter. However when ever I run the program it is unable to find the file. All the documentation I have (web-based plus a Professional Java Server Programming J2EE Edition - way over my head) either skims across it/takes it as read it will be set up correctly/doesn't touch it at all.
    I thought I was trying to access the wrong directory so I mapped the file to the root of C and still can't access it - it always comes back as null. Also between attempts I restart the Tomcat server so it always loads in the web.xml file.
    This is my web.xml:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
      <display-name>Welcome to Tomcat</display-name>
      <description>
         Welcome to Tomcat
      </description>
      <servlet>
        <servlet-name>LogIn</servlet-name>
        <servlet-class>website.LogIn</servlet-class>
        <init-param>
          <param-name>passwordFile</param-name>
          <param-value>C:\\passwords.txt</param-value>
        </init-param>
      </servlet>
      <servlet-mapping>
        <servlet-name>LogIn</servlet-name>
        <url-pattern>/logged</url-pattern>
      </servlet-mapping>
    </web-app>And the Java:
    package website;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    *  Handles the login to the administrators section of the website
    public class LogIn extends HttpServlet
        private String passwordFile;
        /** Read the password file from the location specified
         *  by the passwordFile initialization parameter.
        public void init(ServletConfig config) throws ServletException
            super.init(config);
            passwordFile = config.getInitParameter("passwordFile");
            System.out.println(passwordFile);
            if (passwordFile == null)
                System.out.println("The \"passwordFile\" property must be set to a file name");
            try
            catch (Exception e)
                System.out.println("Error: Unable to read passwordFile.");
        public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
        public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    }It was suggested on comp.lang.java.programmer to check the path that the system was thinking I was searching which I did by inserting this code fragment:
         // initialise the servlet and load password(s)
    //     super.init(config);
    //     passwordFile = config.getInitParameter("passwordFile");
         // added code
         passwordFile = "passwords.txt";
         File f = new File( passwordFile );
         System.out.println( f.getAbsolutePath() );
         // added code.
            ...This lead me to learn that the directory being returned was:
    C:Program Files\Apache Group\Tomcat 4.1\passwordFile.txt
    Which is strange since I would of thought that the lowest directory
    that is visible to the class would of been ROOT (hence it's name).
    Does this mean if I copy the passwordFile.txt to the above directory
    it would work? Actually no. I still can't get the filename as a
    parameter from web.xml which is frustrating. If you could give me any
    pointers on what might be wrong then that would be cool.
    I thought I could move forward by accessing the file directly. But no: An addition of f.exists() to check that the file exists returns false. I've now got a copy of passwords.txt in every single directory from the classes directory all the way down to C:\ and it still doesn't work.
    I hope someone can help out here since this is very frustrating to be stuck on something so basic as file handling.
    Graham Reeds,
    http://omnieng.co.uk | [email protected]

    I can see how this is frustrating but it should be fixable. The last example you posted won't work because you have "passwords.txt" instead of "c:/passwords.txt".
    If you're still looking for a solution could you cut and paste the following code into your servlet code and then post the results?
    // Check that init param is read correctly
    String filename = config.getInitParameter("passwordfile");
    System.out.println("config param = " + filename);
    // try filenames
    String[] filenames = new String[] {"c:/passwords.txt", "c:\\passwords.txt", "passwords.txt"};
    for (int i=0; i < filenames.length; ++i) {           
       File file = new File(filenames);
    System.out.println("File " + filenames[i] + " - exists = " + file.exists());
    System.out.println("Abs path = " + file.getAbsolutePath());
    This is based on the file c:\passwords.txt existing - if I have the wrong filename, please adjust. Also, you may need to change <i> to [[i]i] in a couple of places.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

  • Is it possible to access local files with MIDP?

    Hello everyone,
    I am developing a mobile application using Sun One Studio 4 ME, with MIDP 2.0.
    I am preparing a record store as input data for my application. "Preparing" means: I try to convert a local text file present on my PC into a record store.
    The problem I have is that I cannot find a way in MIDP to allow me to access the local file. It seems to me that MIDP only allows data access over the Web. Am I correct?
    Many thanks in advance for any help or suggestion you could provide.
    Dumitru

    Did you save the messages in a Personal Folder files (PST) or as individual messages on disk? The PST and MSG file formats are proprietary and might not be accessible outside of Outlook.
    If you want to move those messages to a different email program, assuming you have permission to do so, one way is to upload them to an IMAP account (Gmail allows you to connect Outlook as an IMAP client). However, that's pretty complicated, so I suggest researching it on the web, checking at least a few sites to make sure you know all the steps.

  • Problems accessing Music Files in Slideshow module in LR 2.6 and Windows 7 64 bit

         Just got new computer 64 bit Windows 7.  Installed LR 2.6 and am having problem with slideshow and music.  Never had this problem before with my XP computer.  When I open up slideshow module and go to Playback window and check soundtrack and try to choose a music folder, I have a new problem.  It opens up "Browse for Files & Folders" dialog box as usual, but it only lets me browse on my desktop or my User name on the C drive.  My music is in my F drive where my data is stored.  I've never had a problem accessing my music in my F drive in my XP computer, but this setup limits where I can browse to.  Interesetingly, this works OK in LR 3 beta on this WIndows 7 PC where it opens up a dialog box "Choose a music file to play" which gives me access to all my drives.  In summary, I can't access music files stored on a drive other than my C drive using LR 2.6 on a Windows 7 64 bit computer.
         I have attached a screen shot to compare the new Windows 7 Browse for Files & Folders dialog box to that in my XP computer.
         Would appreciate any suggestions.
    Thanks,
    Matthew Kraus

    Thanks for the reply.  I went through the process you suggested to change Ownership  & grant permission to access files.  When I get to the owner tab in Advanced Security Settings....I am already the current owner of this folder.
    What do I do now?
    Thanks,
    Matthew Kraus

  • Problem with Local File Identification in RFC

    Dear all,
    We are working on a scenario where we have to integrate an external application with SAP system. The external application would use SAP DMS as document repository; It will send us a local file path and we have to upload the document located in that path as an attachment to a DMS Document Info Record. We have designed a wrapper RFC for this purpose, which encapsulates the standard Fm BAPI_DOCUMENT_CREATE2. This BAPI takes a file path input under table parameter DOCUMENTFILES. Problem is, when we are running the RFC from SAP GUI, the document info record is created correctly with the document as attachment, but when we invoke the RFC from the external application, the process fails and we get an error message stating:"Error while checking in Original Files". We debugged the scenario and found out that, while running under SAP GUI, the BAPI is able to identify a GUI Link, and hence succeeds; but while calling from the external application, the BAPI fails to find a GUI Link, tries to start a FTP Server using RFC Destination SAPFTP, and fails. So, obviously, the BAPI is not able to parse the local file path because of non-existence of GUI Link. So,in this regard, my question is: is there no way that we can pass a local file path from an external application to SAP, and get the same identified and get the document uploaded? Is there any alternative to our approach?
    Awaiting answers.
    Regards,
    Sid

    Solved the problem by:
    Converting file content to binary->transferring binary content to a wrapper RFC->writing the content into a temporary file in application server->then calling BAPI_DOCUMENT_CREATE2 to create the document without attachment->then calling CVAPI_DOC_CHECKIN to checkin the temporay file from application server.
    Related references:
    http://wiki.sdn.sap.com/wiki/display/PLM/DMSandbackground+processing
    https://websmp130.sap-ag.de/sap/support/notes/504692
    How to upload file from Web Dynpro into R/3 (BAPI_DOCUMENT_CREATE2)
    Thanks to All who have contributed to the Solution.
    Sincere Regards,
    Sid

  • Problem opening local files

    Hi!
    Our servlet has problems opening links to local files. The syntax of the link is correct (file:///program_install_folder/subFolder1/some_file.txt). When user copy-pastes the url to IE's address bar, the file opens without problems, but clicking the link does nothing.
    This has probably something to do with IE's security issues, but:
    1) is there any way to solve this problem with java?
    2) adding the site to trusted sites doesn't help, but is there any other settings which could enable user to open the link to local file?
    Requirement is that program works with Windows XP and IE6.

    servlets run on the server and
    cannot open local client files

  • How the applet can access local file system?

    1. I want to plugin the applet into the JSP. That applet should access the local file system. How to enable this programmatically.
    2. Is it is possible to embed a frame inside the JSP. If so how?
    Thanks in advance..
    K G Vinoth

    1: If you want the applet to access the client's local file system you'll have to sign the applet. There is a tutorial some where on the java.sun.com that explains how to sign an applet.
    2: No you;ll need to use an applet to display swing or awt components on the client browser.

Maybe you are looking for

  • I have two iTouch, how can I use the iMessage if I have both on the same ID account?

    I have two (2) iPod Touch and I recently updated one to iOS5. Both of them are linked on my Apple ID account and I haven't updated yet the other one. But I will like to know if I could use iMessage on both iPods separated with the same Apple ID accou

  • How to get back the data from 'AddressBook.data.previous' ?

    Hi! First of all: After using iSync all my address book data were duplicated, and I deleted all duplicated data manually. Then, I resetted the iSync data under 'Advanced' in '.Mac Sync Preferences'. Unfortunately, iSync deleted all my AddressBook dat

  • Error in xml file validating to xml schema

    Hey, I am getting the following error while validating xml file to its schema: The error is: SAMPLEITEMDLFILE.xml:2,139: no declaration found for element 'WMWROOT' The XML document SAMPLEITEMDLFILE.xml is NOT valid (1 errors) schema file: <?xml versi

  • Multi-touch and Multi-screen

    I just saw the presentations of the PDC2008 (via the net since I couldn't make it to the PDC). It's nice to see that we can add multi-touch functionality to a native, unmanaged application, just handling WM_TOUCH, similar to WM_MOUSE events at this m

  • Add page, not work well

    pages stop showing well.