diff --git a/sparql-anything-cli/src/main/java/com/github/sparqlanything/cli/CLI.java b/sparql-anything-cli/src/main/java/com/github/sparqlanything/cli/CLI.java index b92caa1a..45bbdbd6 100644 --- a/sparql-anything-cli/src/main/java/com/github/sparqlanything/cli/CLI.java +++ b/sparql-anything-cli/src/main/java/com/github/sparqlanything/cli/CLI.java @@ -19,6 +19,7 @@ import org.apache.commons.cli.*; import org.apache.jena.query.Query; +import org.apache.jena.util.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -164,6 +165,9 @@ public String getFormat(Query q) { // Set default format for query type and STDOUT or FILE if (commandLine.getOptionValue(CLI.OUTPUT) != null) { + // Guess the format from the extension + return FileUtils.guessLang(commandLine.getOptionValue(CLI.OUTPUT)); + } else { if (q.isAskType() || q.isSelectType()) { return "JSON"; } else if (q.isConstructType() || q.isDescribeType()) {