×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Sep 2005
    Posts
    138

    Max XML file size ???

    Hi:

    I have a XML file with users:

    Code:
    <user>
        <name> </name>
        <age> </age> 
    ...
    </user>
    <user>
    ...
    When my XML file of users increase over 41 Kb (2'1 Kb compressed in the .jar file) My application crashes when I try to recover the XML file. Not in the parsing, in the recover. Why?

    Than you.

    The method I use to recover the file is:

    Code:
    /** Recupera desde la capa de persistencia un fichero con informacion sobre usuarios
         * @param nombre La ruta del fichero
         * @return El fichero en formato byte[]
         */
        private byte[] recuperarFichero(String nombre){
            
            InputStream miInputStream = this.getClass().getResourceAsStream(nombre);
            String buff = ""; //Aqui almacenamos el recurso en forma de String
            byte[] buffer = new byte[2048];
            
            try{
                int i = miInputStream.read(buffer);
                while (i != -1){
                    buff = buff + (new String(buffer, 0, i));
                    i = miInputStream.read(buffer);
                }
            }catch (Exception ex) {/*ex.printStackTrace()*/System.out.println("Fin de fichero");}
            
            return (buff.getBytes());
        }

    If I use a buffer of 1024 bytes, or 512 bytes, crashes too.

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: Max XML file size ???

    Have not seen this before, but to help people to troubleshoot.. what phone are you using?

    Hartti

  3. #3
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: Max XML file size ???

    hi,

    try using single StringBuffer object instead of creating new Strings and then also using concatenation operation,
    you could simply write bytes into existing string buffer and then create string as results,
    also what parser you're using? you can use InputStream (DataInputStream/StreamInputReader, etc, depending on api used) directly,
    regards,
    Peter

  4. #4
    Regular Contributor
    Join Date
    Sep 2005
    Posts
    138

    Re: Max XML file size ???

    In a 6630 all its ok, but in the WTK 2.2 emulator crashes. In the WTK 2.5 all works.

    I'm using kXML. Can somebody modify the code below? or give me a little bit more information.

    Thank you!

  5. #5
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: Max XML file size ???

    hi,

    full sample:
    Code:
                    InputStream is = null;
                    is = getClass().getResourceAsStream("/resources/data/sample.xml");
                    if(is == null){
                        return;
                    }
                    try {
                        Reader reader = new InputStreamReader(is, "UTF-8");
                        KXmlParser parser = new KXmlParser();
                        parser.setInput(reader);
                        // parse data
                        // ......
                    } catch (UnsupportedEncodingException ex) {
                        ex.printStackTrace();
                    } catch (XmlPullParserException ex) {
                        ex.printStackTrace();
                    } catch(Exception ex){
                        ex.printStackTrace();
                    } finally{
                        if(is != null){
                            try {
                                is.close();
                            } catch (IOException ex) {
                                ex.printStackTrace();
                            }
                        }
                    }
    (without parsing routine though, its up to you),

    regards,
    peter

Similar Threads

  1. S60 theme questions
    By Nokian_Spb in forum Symbian Media (Closed)
    Replies: 3
    Last Post: 2006-08-17, 06:11
  2. Max file size ?
    By f0x in forum Streaming and Video
    Replies: 2
    Last Post: 2004-09-06, 15:37
  3. Open file - Max size of TPtr8
    By nissemark in forum Symbian
    Replies: 0
    Last Post: 2004-08-17, 11:07
  4. problem in sending file size
    By ja_calulot in forum Symbian
    Replies: 0
    Last Post: 2003-12-17, 08:52
  5. What is the max file size supported for the Nokia 6310i using OTA
    By bugs_bunny in forum Mobile Java General
    Replies: 1
    Last Post: 2002-05-10, 14:19

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×