Date: 2011-03-22 11:00:26
From: josemiguelcruztoledo@gmail.com
Hi all,
I have been using bigowlim-3.4.3326 in the past couple of days. I have been
using the GettingStarted.java class found under the getting-started/src/
directories of the bigowlim download, and I noticed that there is a
potential error in the code. The loadFile method makes use of a
BufferedReader and a FileReader but they never get closed. I ran into a "Too
many files open exception" because of this. Therefore, I would recommend a
finally statement is added to the try/catch clause to close the streams,
i.e:
private void loadFile(File file) throws RepositoryException, IOException {
// Invent a context for the graph loaded from the file.
URI context = null;
FileReader fr = null;
BufferedReader br = null;
if(parameters.get(PARAM_CONTEXT) != null){
context = new URIImpl(parameters.get(PARAM_CONTEXT));
} else {
context = new URIImpl(file.toURI().toString());
}
boolean loaded = false;
// Try all formats
for (RDFFormat rdfFormat : allFormats) {
try {
fr = new FileReader(file);
br = new BufferedReader(fr, 1024 * 1024);
repositoryConnection.add(br,"http://example.org/owlim#", rdfFormat,
context);
repositoryConnection.commit();
if (isTrue(PARAM_FLUSH)){
flush();
}
System.out.println("Loaded file '" + file.getName() + "' ("
+ rdfFormat.getName() + ").");
loaded = true;
break;
} catch (UnsupportedRDFormatException e) {
// Format not supported, so try the next format in the list.
} catch (RDFParseException e) {
// Can't parse the file, so it is probably in another format.
// Try the next format.
} finally{
fr.close();
br.close();
}
if (!loaded){
repositoryConnection.rollback();
}
}
if (!loaded)
System.out.println("Failed to load '" + file.getName() + "'.");
}
Regards,
Jose

asked 03 Apr '13, 06:01

Discussion-Board-Archive's gravatar image

Discussion-B...
6.1k133156205
accept rate: 30%


Date: 2011-03-22 17:15:41
From: ivan.peikov@ontotext.com
Hi Jose,
Thanks for pointing that problem out! It is always a pleasure to get comments 
and opinions from people actually using our code!
Your proposed fix will be released as part of OWLIM 3.5 (coming at the end of 
this week).
Cheers,
Ivan
link

answered 03 Apr '13, 06:01

Discussion-Board-Archive's gravatar image

Discussion-B...
6.1k133156205
accept rate: 30%

Date: 2011-03-22 16:19:10
From: barry.bishop@ontotext.com
Hi Jose,
Yes, thanks for your comments. I notice you have also added a context 
command line parameter. If this is also useful then we will add this too.
Perhaps you could send your whole GettingStart.java file and we will 
take it from there?
barry
link

answered 03 Apr '13, 06:02

Discussion-Board-Archive's gravatar image

Discussion-B...
6.1k133156205
accept rate: 30%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×261
×243

Asked: 03 Apr '13, 06:01

Seen: 219 times

Last updated: 13 Jan, 09:23

powered by BitNami OSQA