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

Similar Messages

  • New to J2ME, dont know how to read files on phone mem

    i check all the .io packages, still cant find any class that would help me to read files on phone memory.
    and i see that javax.microedition.media.Manager.createPlayer(String locator), require a string input argu. how can i make this string locator point to a media file on phone memory of TF-card.
    i heard Kjava has some packages from j2se, is there any class would help me? plz someone give me a link of Kjava reference, i cant find it anywhere, thx a lot!

    oh~~~no!
    i am afraid i cant enjoy myself with file conn.
    i tried several times, only to get a "Security Exception", and i contacted with moto dev center, they say that unless i have a cert, i cant use file conn API and many other APIs that is defined as restricted!!!
    and for the cert, if i have a biz relation with moto, they could give a "Develop Certification", or i must pay a third party to get a cert...
    what a world~~~~~~~~~~~is unfair!!!

  • Anybody know how to read "xerces"?? and a lot more......

    And, what's the relationship between xerces and sun's JAXP? Is jaxp more a interface less an implementation? I found jaxp calls some part of xerces pack. Meanwhile, in xerces pack there sits a jaxp pack. Xerces say it support jaxp, so, is that mean xerces is a implementation of jaxp interface?
    Both of the two pack contains some implementation..... I'm confused.
    Can anybody give me an insider's view of jaxp package?
    "The SAX Plugability classes allow an application programmer to provide an implementation of the
    org.xml.sax.DefaultHandler API to a SAXParser implementation and parse XML documents. As the parser processes the XML document, it will call methods on the provided DefaultHandler."
    ------from jaxp1.2 spec
    I'm sorry but English isn't my mother tongue. I'm rather confused by the statements above. Anybody do me a favour to translate it to plain English? Very much thanks.
    Also, what does the following code mean? (from javax.xml.parser.SAXParserFactory.java)
    class FactoryFinder is in nowhere to be found. Can anybody help explain it?
        public static SAXParserFactory newInstance()
            throws FactoryConfigurationError
            try {
                return (SAXParserFactory) FactoryFinder.find(
                    /* The default property name according to the JAXP spec */
                    "javax.xml.parsers.SAXParserFactory",
                    /* The fallback implementation class name */
                    "org.apache.crimson.jaxp.SAXParserFactoryImpl"); //what's this??
            } catch (FactoryFinder.ConfigurationError e) {
                throw new FactoryConfigurationError(e.getException(),
                                                    e.getMessage());
        }Moreover, what the relation between SAXParserFactoryImpl and SAXParserFactory?
    I wrote a program to validate xml files against dtd or schema. Does the package automatically find dtd or schema files within the xml or i have to offer them in the command line? In my case, it seems to be the latter.

    Well, you see, my real problem is that i coded to validate a xml file against xsd or dtd. However, I have to feed the program with a dtd or xsd file in the command line to make it work. Isn't it supposed to find out a proper dtd/xsd in the xml file(when specified)? Or I it isn't properly configured?
    Help me, please!
    Here is the code:
    package xmltool;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import java.io.*;
    * This class validate a xml file against its DTD or Schema.
    * @version 1.1
    * @auther Data Zoe
    public class Check extends DefaultHandler
        /** Constants used for JAXP 1.2 */
        static final String JAXP_SCHEMA_LANGUAGE =
            "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
        static final String W3C_XML_SCHEMA =
            "http://www.w3.org/2001/XMLSchema";
         public static void main(String args[])throws Exception
              //tag varible
              boolean dtdValidate = false;
              boolean xsdValidate = false;
              //xml file to be validated
              String fileName = null;
              //Check input
              for(int i=0;i<args.length;i++)
                        if(args.endsWith(".xml")||args[i].endsWith(".XML"))
                             fileName = args[i];
                        else if(args[i].endsWith(".xsd")||args[i].endsWith(".XSD"))
                             xsdValidate = true;
                        else if(args[i].endsWith(".dtd")||args[i].endsWith(".DTD"))
                             dtdValidate = true;
                        else
                                  System.err.println("Out put usage infomation.");
              if(fileName!=null)
                   SAXParserFactory spf = SAXParserFactory.newInstance();
                   spf.setNamespaceAware(true);
                   spf.setValidating(dtdValidate||xsdValidate);
                   SAXParser saxParser = spf.newSAXParser();
                   XMLReader xmlReader = saxParser.getXMLReader();
                   xmlReader.setContentHandler(new Check());
                   xmlReader.setErrorHandler(new myErrorHandler(System.err));
                   xmlReader.parse(fileName);
                   if (xsdValidate)
                        try     {saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);}
                        catch (SAXNotRecognizedException x)
                                  // This can happen if the parser does not support JAXP 1.2
                                  System.err.println(
                                       "Error: JAXP SAXParser property not recognized: "
                                       + JAXP_SCHEMA_LANGUAGE);
                                  System.err.println(
                                       "Check to see if parser conforms to JAXP 1.2 spec.");
                                  System.exit(1);
              else
                   System.err.println("No xml file to validate");
         * Error handler
         private static class myErrorHandler implements ErrorHandler
              /** Error handler output goes here */
              private PrintStream out;
              myErrorHandler(PrintStream out)
                   this.out = out;
              * Returns a string describing parse exception details
              private String getParseExceptionInfo(SAXParseException spe)
                   String systemId = spe.getSystemId();
                   if (systemId == null)
                        systemId = "null";
                   String info = "URI=" + systemId +
                        " Line=" + spe.getLineNumber() +
                        ": " + spe.getMessage();
                   return info;
              // The following methods are standard SAX ErrorHandler methods.
              // See SAX documentation for more info.
              public void warning(SAXParseException spe) throws SAXException
                   out.println("Warning: " + getParseExceptionInfo(spe));
              public void error(SAXParseException spe) throws SAXException
                   String message = "Error: " + getParseExceptionInfo(spe);
                   throw new SAXException(message);
              public void fatalError(SAXParseException spe) throws SAXException
                   String message = "Fatal Error: " + getParseExceptionInfo(spe);
                   throw new SAXException(message);

  • Does anybody know how to read from a .doc???

    This isn't for a project or anything, just simple curiosity.

    Not sure, I never used it directly. I can tell you that I used JasperReports, and it can output a report to Excel XLS format with all the formating of the original report.
    Best bet would be to read the docs at the URL I provided. It would tell you the specifics better than I can.

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

  • Does anybody know how Oracle load large N-Triple file into Oracle 11g R1?

    Does anybody know how Oracle load large N-Triple(NT) file into Oracle 11g R1 by using sql*loader according to their benchmark results?
    Their benchmark results indicate they have over come the large data set problem.
    http://www.oracle.com/technology/tech/semantic_technologies/htdocs/performance.html
    It means they have loaded LUBM 8000(1.068 Billion+ Triples) into Oracle successfully, but there is no detailed steps provided. For instance, 32-bit or 64-bit platform they used, only one NT file being used corresponding to one dataset or several NT files?
    Is there any exception occured during the loading process if the NT file beyond 60GB? When using jena to generate NT file against LUBM(8000), the size of the NT file would definitely beyond 60GB.
    We are dividing such large NT file into several small ones? Is it a good approach? I'm hesitating to do so!

    A Linux 32-bit platform was used for bulk-load of LUBM-8000 1.106 billion (before duplicate elimination) RDF triples into Oracle.
    Multiple gzipped N-Triple files were used to hold the LUBM-8000 data. zcat was used on all these files together to send the complete data into a named pipe. SQL*Loader used this named pipe as the input data file to load the data into a staging table in Oracle. Once the staging table was loaded, the sem_apis.bulk_load_from_staging_table API was used to load the data into Oracle Semantic Store.
    (Additional details in http://www.oracle.com/technology/tech/semantic_technologies/htdocs/performance.html )
    Thanks.

  • The song _____could not be used because the orignial file could not be found. anybody know how to fix this in windows?

    The song____could not be used, because the original file could not be found. Anybody know how to fix this in windows os?

    I am getting this same message.  I recently bought a new Macbook Pro and the geeks transferred my files from my mini-mac.  Perhaps they did not transfer something critical?  I follow the "locate" option when it asks to find my files and I get a file folder that has a red circle with a white bar in the middle. 
    I have the same issues with my downloaded movies but my apps all seem to be fine.
    Even more confusing - it seems to allow random songs to play and download on my Macbook and other devices.  But most of my music - whether downloaded from iTunes or my CD collection comes up with that message about the original file. 
    Should I get new geeks to locate these files on my old mini-mac?

  • ANYBODY KNOW how to save a swatch in an ID file at a percentage?

    ANYBODY KNOW how to save a swatch in an ID file at a percentage?
    So that every time it's used, it applies that percentage automatically?

    LOL...nevermind. Took me 2 seconds to realize all I needed to do after posting this. Sad trombone.

  • Anybody know how to get a macbook to read the 4gb it is supposed to be expandable to

    anybody know how to get a macbook to read the 4gb it is supposed to be expandable to

    Providing more info as to exactly which model Mac you have and which type of memory modules you acquired will help us diagnose the problem better.

  • Do anybody know how to change a PNG file from 1760 width by 1369 height to 800 x 600?

    Do anybody know how to change a PNG file from 1760 width by 1369 height to 800 x 600?

    Crop to 4x3 aspect ratio, then resize to 800x600

  • I need to erase the contents of my phone and restore to factory settings. Does anybody know how to save your texts so you don't lose them?  Can I back those up to iCloud?  My phone was very likely hacked (Apple's advice was to call the police!)

    "I need to erase the contents of my phone and restore to factory settings. Does anybody know how to save your texts so you don't lose them?  Can I back those up to iCloud?  My phone was very likely hacked (Apple's advice was to call the police!)"
    That was all I could put in the initial "box."  Then it brought me to this page with instructions on how to write a good sentence.
    Proceeding ...
    After going back and forth between Apple, AT&T and the police (all telling me to go to the other two) I took AT&Ts suggestion and got a new number. One tech warned against doing a backup, especially on my Mac, saying if my phone had been hacked then whatever bug was there would then invade my computer. But nobody knows how to determine if the phone has been hacked or a virus was planted there. Unfortunately I know who would have reason to do such a thing and all I can say is that he is at the top technologically and could easily do it. Almost impossible to prove, however.
    So I need to preserve my text messages and my emails as well. I backed up my photos to that Microsoft product (One-Drive) and it froze (Surprise, Surprise) with four short videos to go, and no way of stopping that (when I tried it crashed repeatedly) so I'm in crisis mode here.
    Help ...
    Running 8.0 on 5S
    Thanks!

    Betty I don't know if you fixed your hacking problem but I feel your pain. I've seen some strange things going on between my iMac and my iPhone and Apple has told me the same thing, call the police which I have done. The hackers have stole 500.00 out of my checking account have access to every internet account I use and no matter how often I change the password their right back on the account. I closed my FB account 3 times only to have someone reopen it. Right now I've got a link in my reading list (Safari) that if I click on it, it allows me to log onto my FB account anonymously.
    I've seen a green folder come out of no where while I was trying to delete my passwords out of keychain when that green folder was put into the key chain I was immediately locked out. I than went into system preferences to try to make changes to my security settings, when I clicked on the icon it wouldn't open. I've seen log files of automator receiving commands and sending out my personal information thats on my computer.
    I have a legitamate program called iExplorer that allows you to look at the contents of your iPhone back ups and saw a transaction someone made at the Apple store for some full length movies, some albums, ibooks and other apps but when I called the iTunes store and they said none of those items were showing up on my account. If their not on my account how can they be on my iPhone 6? One day someone was using my gmail account and unknowingly used google maps to search for an Italian restaurant, than a Mexican restaurant than a coffee shop and their search showed up on my iPhone but I didn't have my gmail account installed on my iPhone 6. Using my computer I logged onto my gmail account and looked at the maps history and sure enough there were the searches when I'd hover my curser over the link it gave me the longitude and latitude of the where the hacker was when he was using google maps. I know whoever reads this thinks Im crazy but I've documented everything and can prove the things that I have mentioned in this post actually happened.
    One day I had my laptop (pc) and my iMac next to each other as I was using both. when I clicked on airport it showed that my laptop and my iMac had made a connection and were actually communicating with each other. I know I didn't do it I don't know how. The iMac was logged into my iCloud account while my laptop wasn't. I have formatted my iPhone at least a dozen times, Apple and an Apple retailer have formatted my hard drive not to mention the numerous times I have formatted it but the hackers keep getting on my devices. Im formatting my lap top at this very second because during the course of the night I left the ethernet cable plugged into it and they locked me out of my c: drive, and configured the system so I can't download any updates from Microsoft, overtime I type in www.microsoft.com it changes to ww38.microsoft.com which takes me to a blank page. I right clicked on the page I was redirected to and read the java script and couldn't believe that someone had actually configured Internet Explorer to redirect me to a blank page when I tried to go to Microsoft. Apples answer to all this is there was nothing wrong with my iPhone or my iMac and if I thought there was a problem to call the police which I have done.
    Theres no doubt the hackers are reading this while I type it or will read it and I simply don't care anymore. I no longer email anyone, don't use my iCloud account and have taken precautions to protect my credit but if I ever find out who has invaded my privacy to this extreme the police are going to want to talk to me because Im going to hurt them like they've never been hurt before

  • Hi fellas could anybody know how to get back calendar out from trash to original dock below the screen

    Im having problem getting my calendar out from trash(not deleted) to where this belong to dock below the screen accidently click when im using apps cleaner,i try to swipe my application from trash bin to dock station but keep bounce back to bin,i check on help site said simply open trash bin select the application you want to save,go to top screen see finder then go to file and click say PUT BACK but main issue is that words are grey out ,im on mountain lion version 10.8.4 at the moment for now i can only  use calender by swipe from trash bin to desktop its only i can open than click main dock of calender will say unable to open because it in the trash so can anybody know how to get this out in any way,i dont like to have two icons of calendar on desktop and dock station....i be happy can somebody give advice.......regards

    and prior to that ihave  uploaded my all the photos and videos to icloud from iphoto
    Which part of iCloud are you referring to? iCloud Drive? iCloud Photo Library Beta? My Photo Stream? Shared Photo Stream?

  • Hi, i have edited a clip in hd with final cut, now I need to export it in 2K format . anybody knows how i can do it in FCP?  in internet I found only few info about 2K format: no more than frame size.  nothing about codec or similar. thanks for any help.

    Hi, i have edited a clip in hd with final cut, now I need to export it in 2K format. anybody knows how i can do it in FCP?  in internet I found only few info about 2K format: no more than frame size.  nothing about codec or similar. thanks for any help.

    SoCal thanks for the attention,
    sorry for having wrote the question directly in the subject, but first i wrote it by text edit then copied it, but in the wrong place too.....
    coming to my question, timeline settings are:
    as it is a commercial promo that must be projected in a multiplex cinema, the 2K format is needed.
    I've heard about transcoding services, and they are very expensive. 
    so i'm looking if there is a way to do everything by fcp.
    the project will be delivered as SD DVD for archive pourposes and as a single file for the projection or eventually transconding.
    p.s.: sorry for my english, i'm from italy: had my last english lesson 35 years ago!

  • Does anybody know how to reinstall System Preferences? I accidentaly put System Preferences in the trash and emptied the trash :P

    Does anybody know how to get System Preferences? A couple of weeks ago I put it in the trash and emptied it. Does anyone know how to reinstall it?

    How Restore Deleted or Missing OS X Components
    A few of the basic OS X installed applications can be restored from the Optional Installs installer located in the Optional installs folder on your Installer DVD.  However, if what you need is not there then follow the instructions below.
    How to Use Pacifist to Restore Deleted or Missing OS X Components
    Insert the OS X Installer DVD into the optical drive.  Use a simple utility like TinkerTool to toggle invisibility so you can see invisible items.  Alternatively, open the Terminal application in your Utilities folder and at the prompt enter the following:
    defaults write com.apple.finder AppleShowAllFiles Yes
    Press RETURN.
    To turn off the display of invisible files repeat the above command substituting No for Yes.
    The install packages are located in the /System/Installation/ folder on the DVD.
    Download the shareware utility Pacifist. Use it to extract a fresh copy of the missing item(s) from the file archives on your OS X installation DVD. The file archives are in the /System/Installations/ folder (use Go to Folder option in the Go menu of the Finder.)
    Here are Four Basic ways to use Pacifist (courtesy of George Orville.)
      A. Drag a .pkg icon onto the Pacifist window .....proceed to step 7.
      B. Click on “Open Package ....” and navigate to package desired and click “Open” in
           the open/save window.....proceed to step 7.
      C. Insert Mac OS X installer CD and when it mounts, navigate to .... Menu->Go->Go
           to Folder. In the path field enter or paste ....
    /Volumes/disc name/System/Installation/Packages (where disc name is the name of the CD/DVD that you inserted.)
    Click on the  "Go" button ..... • Drag a .pkg to Pacifist..... proceed to step 7.
    The package you'll need will have to be discovered by trial and error, but for most applications you should start with the Essentials.pkg and/or Additional Essentials.pkg.
    D. Insert your Mac OS X install disk 1 .... and open Pacifist.
    1. In Pacifist, select "Open Mac OS X Install Packages" ... dialog may appear asking for disk 2, then disk 3 and finally disk 1 again.... {if DVD is not used)...If “Stop Loading” is selected...the procedure will stop!!!
    2a. When loading is complete, a new window appears, click the triangle to display contents of each package...Select item and proceed to step 7.
    2b. or click the “Find” icon in the Pacifist window and type the name of the software you need.
    3. In the list that comes back, click the top most entry for the item that you want. ..... that is the one for the English language.
    4. On the top of the Pacifist window, click “verify” .... you will probably be prompted for your password.
    5. Enter checks for.... “verify permissions” and “verify file contents.” and click “verify” ....enter password when prompted.... you will get back output which may look like this:
      20 files were scanned. 20 of 20 files were present on the hard disk. 0 of 20 files had file permissions that did not match those specified in the package. 0 of 20 files had checksums that did not match those specified in the package.
    6. Click “close”. Go to step 7.
    Extract or Install........
    7. In the Toolbar (upper left), you now have the option to extract or install. Click a file in the lower list and those two icons will be enabled.
    8. If “Extract to...” is selected.... navigate to the location where the file will be placed, select “choose”, select “extract” in new dialog that appears,authenicate , if prompted, click “OK”.
    9. In the next dialog, click “Extract”.
    10. If “Install” is selected... dialog will appear with the location/path of the installed software. Click “Install”
    11. Type in your password, click “OK”
    Pacifist will begin to extract files.
    12. In steps 8/10ß.... you also have the choice to “cancel”
    Notes: Pacifist may find that a file it is installing already exists on the hard disk. Pacifist will present you with an alert panel....
      • Stop
      • Leave original alone
      • Update .....
      • Default selection
      • Replace .... (Replace option should only be used on full install packages)

  • Does anybody know how to uninstall MacKeeper?

    I've recently installed MacKeeper. I haven't used it yet but before doing it, I've read it is a malware. I've been trying to uninstall it with no success. My computer is starting to go wrong and slower. Does anybody know how to uninstall it?

    "MacKeeper" is a scam with only one useful feature: it deletes itself.
    First, back up all data.
    Note: These instructions apply to the version of the product that I downloaded and tested in early 2012. I can't be sure that they apply to other versions.
    If you have incompletely removed MacKeeper—for example, by dragging the application to the Trash and immediately emptying—then you'll have to reinstall it and start over.
    IMPORTANT: "MacKeeper" has what the developer calls an “encryption” feature. In my tests, I didn't try to verify what this feature really does. If you used it to “encrypt” any of your files, “decrypt” them before you uninstall, or (preferably) restore the files from backups made before they were “encrypted.” As the developer is not trustworthy, you should assume that the "decrypted" files are corrupt unless proven otherwise.
    In the Finder, select
              Go ▹ Applications
    from the menu bar, or press the key combination shift-command-A. The "MacKeeper" application is in the folder that opens. Quit it if it's running, then drag it to the Trash. You'll be prompted for your login password. Click the Uninstall MacKeeper button in the dialog that appears. All the other functional components of the software will be deleted. Restart the computer and empty the Trash.
    ☞ Quit MacKeeper before dragging it to the Trash.
    ☞ Let MacKeeper delete its other components before you empty the Trash.
    ☞ Don't try to drag the MacKeeper Dock icon to the Trash.
    ☞ Don't try to remove MacKeeper while running in safe mode.

Maybe you are looking for

  • Where to see the updated data for transaction IQ02.

    Hi All, I have to write the enhancement to update the transaction IQ02 by menas of BAPI or any FM. Before that i tried updating the equipemt view for the material numbar and serial numbar combination from transaction IQ02. how do i do it manually so

  • Canon Powershot G7 won't connect

    When I connect my Canon Powershot G7 to my MacBook (unibody) running OSX 10.6.4, it won't recognize my camera. Using Eos Utility, iPhoto and Aperture won't work. Other cameras do work without any problem. I understand that I can move the card to a re

  • Oracle linux 6.5 - yum update

    Hello, my update is ending by following error: Transaction Check Error:   file /lib/firmware/isci/isci_firmware.bin from install of kernel-firmware-2.6.32-431.29.2.el6.noarch conflicts with file from package kernel-uek-firmware-2.6.32-100.35.1.el6uek

  • HttpSession Invalidate not working with WAS LTPA

    I normally handle site logout with a JSP that executes <% session.invalidate(); %> then redirects to the home page. Now I am running on WebSphere Application Server 5.1 authenticating against a Novell eDirectory LDAP server using LTPA and a SSL Certi

  • Using EJB remote session beans llike webservice.

    My requirement is to fetch a big size ASCII stream file from a remote location. For this can I use Statless EJB Session beans? For this EJB application & Web application will be on my application server side & EJB client should reside on the remote e