Skip to content

Commit f405cf4

Browse files
committed
Try to import as regular bibtex file before trying anything else
1 parent 6f9c748 commit f405cf4

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/main/java/net/sf/jabref/importer/ImportFormatReader.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,18 @@ public UnknownFormatImport importUnknownFormat(String filename) {
362362
int bestResultCount = 0;
363363
String bestFormatName = null;
364364

365+
// First, see if it is a BibTeX file:
366+
try {
367+
ParserResult pr = OpenDatabaseAction.loadDatabase(new File(filename),
368+
Globals.prefs.getDefaultEncoding());
369+
if ((pr.getDatabase().getEntryCount() > 0)
370+
|| (pr.getDatabase().getStringCount() > 0)) {
371+
pr.setFile(new File(filename));
372+
return new UnknownFormatImport(ImportFormatReader.BIBTEX_FORMAT, pr);
373+
}
374+
} catch (Throwable ignore) {
375+
}
376+
365377
// Cycle through all importers:
366378
for (ImportFormat imFo : getImportFormats()) {
367379

@@ -393,19 +405,6 @@ public UnknownFormatImport importUnknownFormat(String filename) {
393405
return new UnknownFormatImport(bestFormatName, parserResult);
394406
}
395407

396-
// Finally, if all else fails, see if it is a BibTeX file:
397-
try {
398-
ParserResult pr = OpenDatabaseAction.loadDatabase(new File(filename),
399-
Globals.prefs.getDefaultEncoding());
400-
if ((pr.getDatabase().getEntryCount() > 0)
401-
|| (pr.getDatabase().getStringCount() > 0)) {
402-
pr.setFile(new File(filename));
403-
return new UnknownFormatImport(ImportFormatReader.BIBTEX_FORMAT, pr);
404-
}
405-
} catch (Throwable ex) {
406-
return null;
407-
}
408-
409408
return null;
410409
}
411410
}

0 commit comments

Comments
 (0)