The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

CWollnik (2) [Avatar] Offline
#1
Code Snippet:
ContentHandler handler = new BodyContentHandler();
ParseContext context = new ParseContext();
context.set(Parser.class, parser);
try {
parser.parse(is, handler, metadata,
new ParseContext());
} finally {
is.close();
}

should probably be instead:
ContentHandler handler = new BodyContentHandler();
ParseContext context = new ParseContext();
context.set(Parser.class, parser);
try {
parser.parse(is, handler, metadata,
context);
} finally {
is.close();
}

Would be glad to have that confirmed/disconfirmed
mike.mccandless (221) [Avatar] Offline
#2
Re: Errata 244
Woops, you are correct!! I'll note this in our local ERRATA file...
CWollnik (2) [Avatar] Offline
#3
Re: Errata 244
In this case, you might also want to change the same code part, page 243

TikaConfig config = TikaConfig.getDefaultConfig();
List<String> parsers = new ArrayList<String>(config.getParsers()
.keySet());
Collections.sort(parsers);
Iterator<String> it = parsers.iterator();
System.out.println("Mime type parsers:");
while(it.hasNext()) {
System.out.println(" " + it.next());
}

to

TikaConfig config = TikaConfig.getDefaultConfig();
List<MediaType> parsers = new ArrayList<MediaType>(config.getParsers().keySet());
Collections.sort(parsers);
Iterator<MediaType> it = parsers.iterator();
System.out.println("Mime type parsers:");
while (it.hasNext()) {
System.out.println(" " + it.next());
}
System.out.println();

With that changes included, it runs as test code - Hope having helped
mike.mccandless (221) [Avatar] Offline
#4
Re: Errata 244
Thanks, will do!