Retrieving .txt file from JAR

I guess this is a newbie question but i checked the tutorial sessions and i am doing exactly what it says there but still...no luck:
I'm trying to access a .txt. file stored in the .jar file where my applet .class file is stored. I'm using:
String s = "myfile.txt";
// get current Class loader
ClassLoader cl = this.getClass().getClassLoader();
FileInputStream is = new FileInputStream((cl.getResource(s)).toString());
BufferedReader in = new BufferedReader(new InputStreamReader(is));But when the applet is viewed from the browser or from the appletviewer, i'm getting the FileNotFoundException:
java.io.FileNotFoundException: jar:file:\C:\FeatureSelection\sFeatureSelection.jar!\myfile.txt (The filename, directory name, or volume label syntax is incorrect)
I tried to use the following instead:
FileInputStream is = new FileInputStream((myApplet.class.getResource(s)).toString());orFileInputStream is = new FileInputStream((getClass().getResource(s)).toString());but the same exception is still there.
The jar file and the html file are all stored in this directory C:\FeatureSelection\
The signed jar file is called sFeatureSelection.jar
Any help would be greatly appreciated!
Thanks.

Thanks for your help, but i'm still getting the same exception:
java.io.FileNotFoundException: file:\c:\FeatureSelection\sFeatureSelection.jar!\myfile.txt (The filename, directory name, or volume label syntax is incorrect).
As for the JarInputStream, i checked it out online, but i'm not too sure how i can use these methods to apply'em for my problem here. Does anyone have a sample code that uses JarInputStream?
Thanks.

Similar Messages

  • Retrieving .txt file from jar for an applet

    I guess this is a newbie question but i checked the tutorial sessions and i am doing exactly what it says there but still...no luck:
    I'm trying to access a .txt. file stored in the .jar file where my applet .class file is stored. I'm using:
    String s = "myfile.txt";
    // get current Class loader
    ClassLoader cl = this.getClass().getClassLoader();
    FileInputStream is = new FileInputStream((cl.getResource(s)).toString());
    BufferedReader in = new BufferedReader(new InputStreamReader(is));But when the applet is viewer from the browser or from the appletviewer, i'm getting the FileNotFoundException:
    java.io.FileNotFoundException: jar:file:\C:\FeatureSelection\sFeatureSelection.jar!\myfile.txt (The filename, directory name, or volume label syntax is incorrect)
    I tried to use the following instead:
    FileInputStream is = new FileInputStream((myApplet.class.getResource(s)).toString());orFileInputStream is = new FileInputStream((getClass().getResource(s)).toString());but the same exception is still there.
    The jar file and the html file are all stored in this directory C:\FeatureSelection\
    The signed jar file is called sFeatureSelection.jar
    Any help would be greatly appreciated!
    Thanks.

    One way to get at files in a jar is to put the jar in the CLASSPATH and then just refer to the resource by its path in the jar. If the same path occurs in two different jars, then you only get the first one, based on the order of the jars in CLASSPATH, I think.
    The classloader is involved, which can be confusing, but an easy way to try this is:
    String s = "myfile.txt";
    URL u = this.class.getClassLoader().getResource(s);
    Object o = u.getContent();Now, you only really know that something matched that path and now it is in a URL.
    I think the Object will be a stream and you have to read() it or something.
    BTW: I encourage you to examine the URL, but it is not necessary to do so.
    If you have somehitng like a GIF image, then here is an example of how to work with that:
    http://www.devx.com/tips/Tip/5697
    Here is a way to get the bytes without involved the ClassLoader:
    http://www.javaworld.com/javaworld/javatips/jw-javatip49.html
    Take your pick.

  • Need to copy .txt file from FTP server and downloaded on local server directory.

    I need to figure out a way to copy .txt file from ftp server in local server directory using sql jobs.

    Below links will help achieving it:
    https://www.virtualobjectives.com.au/sqlserver/ftp_scripts.htm
    http://www.mssqltips.com/sqlservertip/2884/sql-server-integration-services-ssis-ftp-task-for-data-exchange/

  • Help reading a .txt file from the hard drive....

    Hi guys,
    Ok... I need to know how to read a .txt file from the hard drive... I have an example on how to read from a disk, but I don't have a disk drive. I could be confusing terminology, but I don't think I am. Here is the code I have for reading from a disk.. please let me know how I should change it to read from a hard drive.
    Also, when the error pops up, it says that it can't read another .txt file that is not specified in the code... any ideas how that is occuring? Please advise.
    import java.io.*;
    public class TEST {
    public static void main(String args[]) throws Exception{
    FileReader fr = new FileReader("customer.txt");
    BufferedReader bfr = new BufferedReader (fr);
    String s;
    while ((s=bfr.readLine())!= null){
    System.out.println (s);
    fr.close();
    }

    Ok... I need to know how to read a .txt file from the
    hard drive... I have an example on how to read from a
    disk, but I don't have a disk drive. I could be
    confusing terminology, but I don't think I am. Here
    is the code I have for reading from a disk.. please
    let me know how I should change it to read from a
    hard drive.The code will be the same, regardless of where the file is located. It's just the filename that will be different.
    Also, when the error pops up, it says that it can't
    read another .txt file that is not specified in the
    code... any ideas how that is occuring? Please
    advise.Probably becuase the class file (compiled version of the source code) is a different version to the source code, i.e. the source code hasn't been recompiled since the source code was changed.
    How does this relate to EJBs?

  • How do I retrieve a file from Trash using Time Machine in Mavericks?

    Is it even possible to retrieve a file from Trash from a Time Machine backup? Does Time Machine even back up the Trash? I've been told a total restore from a Time Machine backup will put the past Trash back on the Mac, but what if I just want to restore an individual file?
    Shortly after emptying my Trash on my Mac (10.9.4) for the first time in weeks, I realized I needed one of the files I'd just erased. Trying to retrieve with Time Machine was not fruitful, however, because I couldn't find the file on any of the past backups using the normal Enter Time Machine interface. However, I know it would have been in the Trash during all of the most recent backups.
    So I researched how to find the backups of Trash with Time Machine, but I think all of the solutions I found on various online forums were pre-Mavericks and do not seem to work now. I've basically tried 2 things:
    Show Trash in Finder using the Terminal command: open ~/.Trash
    It shows the hidden Trash folder in Finder, located in Macintosh HD/Users/User. For easy access, I added the .Trash folder to the Finder Sidebar. But I can't get to it in the backups. The Trash shortcut in the Finder Sidebar is always grayed out in the old backups using the Time Machine app. And it does not show up in ~ when looking through the backups.backupdb folder on my external HD.
    I also tried the Terminal command to show all hidden files in Finder: defaults write com.apple.finder AppleShowAllFiles YES
    But while many hidden files do suddenly appear in Finder, curiously, the User's .Trash folder is not one. This is true for the Finder of the Mac, the backups.backupdb folder on the External HD, and Time Machine app.
    Thanks.

    How do I retrieve a file from my backup in Time Capsule?
    It depends on the type of file that you are trying to retreive.
    In general.....
    Open Time Machine by clicking on the clock icon on the dock
    Wait a few minutes for Time Machine to fully load
    Use the timeline at the far right of the window to go back in time to a date when the file was still on your Mac
    Click that date
    Navigate using the Finder interface to locate the file that you want
    Click on the file to highlight it
    Click Restore at the lower right of the window to be brought back to the present
    You have to retrieve other types of files differently. For details, see:
    http://pondini.org/TM/28.html

  • "Error retrieving xml file from database"

    Hello All,
    I have installed and configured planning with Shared services. While I try to create an instance in Configuration Utility by entering the Instance Name, Host Name, Port (8300) and Click "Next", I get this error -
    *"System failure:Error retrieving xml file from database".*
    My RDBMS is - SQL Server 2005
    OS - Windows 2003 Server
    I am unable to work on planning for few months due to this error.. I would sincerely appreciate if someone can provide me a solution for this..
    Thanks much,
    Varma.

    Hi,
    Ive seen this before.
    If this is a new environment could you create a blank database and configure it as your System database? Then try again and you should be fine.
    I think you may have some invalid entries in your sys database.
    Seb
    www.taysols.com.au

  • Product Instance Registration Error Message: "System Failure: Error while retrieving xml file from database"

    Hi Planning installation Gurus,
    Did u get any luck to resolve this problem as i am also facing same problem "Error creating instance" during install of Planning 9.3.1. i tried 30-50 times reconfiguration every time same problem..
    OS: Vista Premium
    SQL Server 2005
    Essbase:9.3.1
    Error Message: "System Failure: Error while retrieving xml file from database"
    Details of error:::::::::::::::::::::::::
    at com.hyperion.planning.event.HspSysExtChangeHandler.run(Unknown Source
    Can not get JDBC connection for SYS external changed actions.
    Can not get JDBC connection.
    java.lang.NullPointerException
    at com.hyperion.planning.sql.HspSQLImpl.getConnection(Unknown Source)
    at com.hyperion.planning.event.HspSysExtChangeHandler.actionPoller(Unkno
    wn Source)
    at com.hyperion.planning.event.HspSysExtChangeHandler.run(Unknown Source
    Can not get JDBC connection for SYS external changed actions.
    Can not get JDBC connection.
    java.lang.NullPointerException
    at com.hyperion.planning.sql.HspSQLImpl.getConnection(Unknown Source)
    at com.hyperion.planning.event.HspSysExtChangeHandler.actionPoller(Unkno
    wn Source)
    at com.hyperion.planning.event.HspSysExtChangeHandler.run(Unknown Source
    Can not get JDBC connection for SYS external changed actions.
    Can not get JDBC connection.
    Pls provide Solution

    Hi John,
    though i am trying with SQl server authentication with different user but still status is same of planningSystemDB.properties
    SYSTEM_DB_DRIVER=hyperion.jdbc.sqlserver.SQLServerDriver
    SYSTEM_DB_URL=jdbc:hyperion:sqlserver://neeraj-PC:1433
    SYSTEM_DB_USER=windowsAuthentication
    SYSTEM_DB_PASSWORD=CAFBAEFNBGEAABHEDOADFKADACBGBIFHBLCDFBAFFH
    SYSTEM_DB_CATALOG=plandb
    SYSTEM_DB_TYPE=SQL
    INSTANCE=
    my steps:
    Using SQL Server Management Studio
    Changed Widows authentication to SQL server authentication mode
    In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.
    On the Security page, under Server authentication, select the new server authentication mode, and then click OK.
    In the SQL Server Management Studio dialog box, click OK to acknowledge the requirement to restart SQL Server.
    In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.
    On the Security page, under Server authentication, select the new server authentication mode, and then click OK.
    In the SQL Server Management Studio dialog box, click OK to acknowledge the requirement to restart SQL Server.
    To restart SQL Server from SQL Server Management Studio
    To enable the sa login by using Management Studio
    In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties.
    On the General page, you might have to create and confirm a password for the sa login.
    On the Status page, in the Login section, click Enabled, and then click OK.
    In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties.
    On the General page, you might have to create and confirm a password for the sa login.
    On the Status page, in the Login section, click Enabled, and then click OK.}}}
    anything else should i change.................

  • Product Instance Registration Error: "System Failure: Error while retrieving xml file from database"

    Hi S9 installation Gurus,
    Please try to resolve this long awaited issue with Planning installation as this is purely configuration related issue.
    Detail of Problem:-
    After Susessful configuration of
    1) Foundation Services (Hyperion Shared Services)
    2) Essbase administration services
    3) Essbase Server
    4) Hyperion reporting and analysis
    5) Planning -----> Product options, Register with shared services, configure database, deploy to application server (Appache)
    Error Point: when i tick ckeck box in front of Product instance registration
    click next
    create instance
    click next
    instance name-Plan1
    Web tier host name: my machine name (neeraj-pc, as i installed locally all component of hyperion)
    server port: 8300 (system suggesting)
    tick on active instance
    click next
    Error Pop Up "System Failure: Error while retrieving xml file from database"
    Details of PlanningSystemDB (file :- \Hyperion\common\config\PlanningSystemDB.properties)
    SYSTEM_DB_DRIVER=hyperion.jdbc.sqlserver.SQLServerDriver
    SYSTEM_DB_URL=jdbc:hyperion:sqlserver://neeraj-PC:1433
    SYSTEM_DB_USER=puser
    SYSTEM_DB_PASSWORD=GGAKFJ
    SYSTEM_DB_CATALOG=p1db
    SYSTEM_DB_TYPE=SQL
    INSTANCE=
    Note: puser (SQL Authenticated user)
    Thanks
    Kumar
    Edited by: user10385300 on Dec 4, 2008 5:44 AM

    This has been resolved at :- Product Instance Registration Error Message: "System Failure: Error while retrieving xml file from database"
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Reading .txt file from remote using abap?

    Hi,
    I must read a .txt file from remote server automatically.
    I have path and name of .txt file. Remote system asks username and password.
    In abap is it possible to give username and password for reading .txt from remote server?
    Remote server and sap server are not in same domain.
    How can i do that?
    Thanks.

    Hi Cemil ,
      You can try using the FM RZL_READ_FILE_REMOTE_SH.
    This is an option i found ,  but i have really not tried it out .
    Regadrs
    Arun

  • Is it possible to retrieve deleted files from the cloud i.e. contact list?

    Is it possible to retrieve deleted files from the cloud i.e. contacts?

    If you have an iCloud backup of an iOS device that was made while the contacts were still on it, you may be able to restore them from the backup by following this user tip from Winston Churchill: https://discussions.apple.com/docs/DOC-4841.

  • How to retrieve full flash solution from WSP if not than how to retrieve ascx files from Template folder in SharePoint 2013 ?

    How to retrieve ascx file from the Template folder in SharePoint2013
    My issue is, I have WSP only so I changed into zip and got my all web parts and also one dll file after that decrypted dll and got some C# code
    mixing with some system generated code but not ascx file that is for front-end part. So my question is how we can retrieve full flash solution if not, at least ascx files So if we were on SharePoint 2010 we could have got those file from __Template__
    folder but It’s on SharePoint 2013 and not able to get ascx.
    If we can do so, than will be easy to get the task to be done
    Suggestions would highly be appreciated. Thanks in Advance.
    Ashish

    Hi Amit,
    you can not move specific changes from Dev to production.
    but you can follow this process to make your workflow as it is as in Dev:
    Create a new workflow on the new list in Product.
    Create at least one step, one condition and one action in this workflow.
    1. In Dev server open your .xomal file as XML and copy the entire contents.
    2.In Production server Open your .xoml file as XML and Paste the entire contents
    3. repeat this operation for the xoml.rules file
    4.Double click the .xoml file for the new workflow to open the workflow in the Workflow Designer and click Check Workflow to verify no errors and then click Finish to ensure the workflow is saved.
    Whenever you need to make changes apply the same.
    Please Mark Answer and Vote me if it will to resolve your issue

  • Why can't I open and retrieve my files from iPhoto and my address book after importing the files from my Power mac G5 to my new Mac Pro? I get a warning that says the new OS on my Pro doesn't open files from a Power Mac. Any idea how I can fix this?

    Why can't I open and retrieve my files from iPhoto and my Address Book after importing the files from my Power Mac G5 to my new Mac Pro? I get a warning that says the new OS on my Pro doesn't open files from a Power Mac. Any idea how I can fix this?

    For your addressbook, export the files to vCard on the PowerMac, then bring them over to your Mac Pro. For your iPhoto, copy the Users -> yourname -> Pictures folder to your Desktop on the Mac Pro, and open iPhoto on the Mac Pro holding the command and option keys.  Select the library file from that Pictures folder and open it.  It should import all the pictures into iPhoto as part of the rebuild process.  Other PowerPC to Intel migration issues are covered here: https://discussions.apple.com/docs/DOC-2295

  • I restore my iphone before i backed it up. any chance to retrieve my files from my iphone?

    i restore my iphone before i backed it up. any chance to retrieve my files from my iphone?

    You, or somebody with access to your phone, must have set this up.
    "If your backup is encrypted, iTunes asks you to enter the password before restoring your files and settings. Encrypted backups display a lock icon in the list of backups in iTunes Devices preferences."
    http://support.apple.com/kb/PH1779

  • "Bad data format" when reading txt file from the presentation server

    Hello,
    I have a piece of code which reads a txt file from the presentation server to an internal table like below:
    DATA : lv_filename type string.
    lv_filename = 'C:\abap\Test.txt'. "I created a folder called abap under C:\
    CALL method CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
    EXPORTING
       FILENAME              = lv_filename
    CHANGING
       DATA_TAB            = lt_tsd. " lt_tab has the exact same fields as the Test.txt's. Test.txt has only one line, tab delimited.
    When running this code, exception BAD_DATA_FORMAT is issued.
    Is it because of the file encoding or delimiter or other reason?
    Thanks,
    Yang

    Hello,
    If its tab delimited then use the has_field_seperator parameter and check
    DATA : lv_filename type string.
    lv_filename = 'C:\abap\Test.txt'. "I created a folder called abap under C:\
    CALL method CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
    EXPORTING
       FILENAME                = lv_filename
       FILETYPE                 = 'ASC'
       HAS_FIELD_SEPARATOR          = u2018Xu2019
    CHANGING
       DATA_TAB            = lt_tsd.
    Vikranth

  • Create an outbound flat file .txt file from SAP to UAPM.

    How to Create an outbound flat file .txt file from SAP to UAPM (Unicenter Asset Portfolio Management).

    What do u want in flat file and what is your doubt please let me know as iam working i can help u

Maybe you are looking for

  • How do i find out what is behind names like"artist - track1"

    hi guys, i'm new to itunes and i'm using it since a week or so, its simply amazing. the bad side is that i recognized that almost 20% of my music has no id3tags. So itunes list them with names like "artist - track4 - album" and so on. but in my explo

  • Ipod Touch is Dead!

    I have a new desktop running Vista (old PC runs XP). I installed itunes and plugged my itouch in and it wouldn't sync – it kept giving a read / write error. A restore didn't help so I scoured this forum and in desperation rang Apple yesterday. The la

  • Pricing Procedure for PO Header

    we have created a condition type ZPB2 by copying condition type ZPB0 (which is automatic gross price condition type). basically the ZPB2 copies the value from ZPB0 and should keep the value statistic. and the value is used in sales pricing for interc

  • IPhoto remove all iCloud pictures and reload form iCloud when I opened via Aperture

    Hi, I have almost 100GB iCloud pictures & moves. When I open a Aperture library via iPhoto, every time iPhoto remove all iCloud pictures, and let me enable iCloud photo again. So I must still wait iPhoto finish download all iCloud pictures again. It

  • Automatically Start Time Machine

    Since upgrading to OS X Mavericks over a month ago, I have to open Time Machine Preferences and select my external HD/disk EVERY time that I reboot my iMac.  Otherwise, Time Machine will not start despite the TM slide being "On."  I was talking with