Well, there was no error during runtime, it was just that the data was erased. After debugging it with a print statement, System.out.println(in.read());, I discovered that the InputStream was being erased after I called the detect(InputStream in) method.
On Mon, Sep 30, 2013 at 11:19 AM, Sergey Beryozkin <[email protected]>wrote: > Hi > > On 30/09/13 15:49, kevin slote wrote: > >> Ok, thanks. That was my problem. Also, I read your book and enjoyed it >> very much. Is this the forum where I could bring up an issue I found with >> the Tika-JAX-RS server? >> >> What kind of issue are you seeing ? > > Sergey > > >> On Mon, Sep 30, 2013 at 10:45 AM, Jukka Zitting <[email protected]> >> **wrote: >> >> Hi, >>> >>> On Mon, Sep 30, 2013 at 10:36 AM, kevin slote <[email protected]> wrote: >>> >>>> InputStream in= attachment.getFileInputStream(**); >>>> [...] >>>> String mime = tika.detect(in); >>>> >>> >>> See the javadocs [1]: "If the document stream supports the mark >>> feature, then the stream is marked and reset to the original position >>> before this method returns" >>> >>> I believe the stream you're using does not support the mark feature >>> (see [2]), which makes it impossible for Tika to restore the original >>> state of the stream once type detection is done. >>> >>> Using BufferedInputStream [3] should fix your problem: >>> >>> InputStream in= new >>> BufferedInputStream(**attachment.getFileInputStream(**)); >>> >>> [1] >>> http://tika.apache.org/1.4/**api/org/apache/tika/Tika.html#** >>> detect(java.io.InputStream)<http://tika.apache.org/1.4/api/org/apache/tika/Tika.html#detect(java.io.InputStream)> >>> [2] >>> http://docs.oracle.com/javase/**7/docs/api/java/io/** >>> InputStream.html#mark(int)<http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html#mark(int)> >>> [3] >>> http://docs.oracle.com/javase/**7/docs/api/java/io/** >>> BufferedInputStream.html<http://docs.oracle.com/javase/7/docs/api/java/io/BufferedInputStream.html> >>> >>> BR, >>> >>> Jukka Zitting >>> >>> >> >
