Mar 25

When an XML parser encounters an error while parsing it generally just gives up. Sometimes this is not what we want and would instead would like it to soldier on.

In these case Xerces has a useful feature that allows you to instruct it to continue parsing

parser.setFeature(
   "http://apache.org/xml/features/continue-after-fatal-error", 
   true);

Once that is set the parser will happily continue parsing even after it has encountered an error.

written by objects \\ tags: , ,

Mar 18

Recently was updating my notes using Evernote from my iphone and recieved the following error:

Synchronization failed.
Unknown error u11

After searching google found a few discussions about the problems and some suggested fixes. Not all of these fixes worked, for example logging out and logging back in made no differences.

The consensus of opinion was that the root cause was html with url’s in the note, in particular strange characters in the url. This turned out to be the problem in my case and once the offending characters (% in my case) in the href url was removed the error vanished and syncing went back to normal.

Cannot say this will help everyone with this problem, but hopefully it helps someone. With any luck Evernote can fix this problem in an upcoming release of what is a great application.

written by Obiweb \\ tags: , ,

Mar 10

When using URLConnection (HttpURLConnection actually) to send a large POST you can often get a OutOfMemoryError, for example when POSTing a large file.

Reason for this is that by default HttpURLConnection buffers the entire POST to enable it to set the content length for the request.

If you already know the content length in advance (for example when sending a file) you can use streaming mode.

HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
connection.setFixedLengthStreamingMode(file.length());

// now write file to connections output stream

written by objects \\ tags: , , , ,