ParseUtils.getStringContent

View: New views
2 Messages — Rating Filter:   Alert me  

ParseUtils.getStringContent

by Guillaume LOUVEL :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I test Tika projet, and I like it, it is very useful.
I use the ParseUtils.getStringContent() like this :

ParseUtils.getStringContent(myfile, TikaConfig.getDefaultConfig();

I have a NullPointerException if the mime type is application/octet-stream.
Is it normal ? I download the source and I test, I found this arrived in
the

public static String getStringContent(InputStream stream, TikaConfig
config, String mimeType) throws TikaException, IOException {
        try {
            Parser parser = config.getParser(mimeType);
            ContentHandler handler = new BodyContentHandler();
            parser.parse(stream, handler, new Metadata());
            return handler.toString();
        }
        catch (SAXException e) {
            throw new TikaException("Unexpected SAX error", e);
        }
    }

If the mimetype is application/octet-stream, the line
Parser parser = config.getParser(mimeType);
return a null object

and the line
parser.parse(stream, handler, new Metadata());
throw a NullPointerException

Is it normal ?

Thank's for this good project.

Guillaume LOUVEL

Re: ParseUtils.getStringContent

by Jukka Zitting :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Wed, May 28, 2008 at 4:05 PM, Guillaume LOUVEL <louvel@...> wrote:
> I use the ParseUtils.getStringContent() like this :
>
> ParseUtils.getStringContent(myfile, TikaConfig.getDefaultConfig();
>
> I have a NullPointerException if the mime type is application/octet-stream.
> Is it normal?

The ParseUtils hasn't been actively looked at lately so there may well
be errors like this. You may want to file a bug report about this.

BR,

Jukka Zitting
LightInTheBox - Buy quality products at wholesale price