Results 1 to 6 of 6

Thread: Malformed exception in java

  1. #1
    Join Date
    Mar 2010
    Posts
    162

    Malformed exception in java

    Hello,
    I want my application to retrieve and open a file. Property to avoid having thereafter (if changing servers, etc ...) recompile my java program.
    Then the path is recovered:
    Here is the code which I use for it
    Code:
    String rlpth = request.getRealPath("check.properties");
    But I am getting an malformed exception in java. What is the reason for it. If you know please let me know. Thanks in advance.

  2. #2
    Join Date
    Nov 2009
    Posts
    583

    Re: exception in java

    Hello,
    It is possible that it comes from inside your file "checkIdentity.properties. Apparently if it contains a \ u this can cause problems (if so, try to double the \). If you need more help on the API's which are used in the java programming language then you can visit the official site of sun and there you can find all the API's which are used in the java programming language.

  3. #3
    Join Date
    Nov 2009
    Posts
    356

    Re: Malformed exception in java

    Hello,
    The problem is not the path name but the contents of your file *. properties: the \ must be doubled if they are interpreted (\ n for a newline, \ u0000 for unicode, etc..).
    Take a look at the following code
    Code:
    Properties pr = new Properties();
    InputStream instrm = new FileInputStream(RealPath);
    try {
        pr file.load(instrm);
    } finally {
       instrm.close();
    }

  4. #4
    Join Date
    Nov 2009
    Posts
    446

    Re: Malformed exception in java

    Hello,
    To settle the problem immediately you can remove all my addresses *. properties file contains:
    Here is the part of code for it
    Code:
    user = theusrnm
    pass = PASSWORD
    defaultBdocUserId = usrid
    So no escape character, however you can have exactly the same error message, but atleast you can try it once.

  5. #5
    Join Date
    Mar 2010
    Posts
    162

    Re: Malformed exception in java

    Hello,
    Here I use a new method to take no further problems
    Code:
    request.getRealPath
    comparing to this I use something like this
    Code:
    ...
            ServletContext cnt = config.getServletContext();
            path = cnt.getRealPath("checkIdentity.properties");
    ...
    This code gives me more warning if I do a "print" the result of path well get the full address of my file so normally the correct path ...
    Code:
    d: \ Tomcat5.0 \ webapps \ checkNew \ ...................
    Any help on this.

  6. #6
    Join Date
    Nov 2009
    Posts
    330

    Re: Malformed exception in java

    Hello,
    Check the updated code
    Code:
    Properties pr = new Properties();
    InputStream instrm =null;
    try 
            {
                instrm = new FileInputStream(path);
                pr file.load(instrm);
                cacheConnectionString = pr.getProperty("cacheConnectionString");
                ur = pr.getProperty("ur");
                ps = pr.getProperty("ps");
                out.System.out.println("ur ="+ ur +"Pass ="+ ps);
            } catch ....

Similar Threads

  1. Exception in Java Web Start
    By Jaganmohini in forum Software Development
    Replies: 6
    Last Post: 27-07-2010, 01:15 PM
  2. Headless Exception in Java
    By Adrina_g in forum Software Development
    Replies: 5
    Last Post: 20-02-2010, 08:36 PM
  3. How to catch an Exception in Java?
    By SKREECH in forum Software Development
    Replies: 4
    Last Post: 18-02-2010, 04:50 AM
  4. Exception in java input/output
    By Aaliya Seth in forum Software Development
    Replies: 5
    Last Post: 22-01-2010, 12:05 PM
  5. Code for Exception in Java
    By taher in forum Software Development
    Replies: 4
    Last Post: 15-01-2010, 09:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,710,842,260.37203 seconds with 16 queries