org.apache.jena.atlas.io.IO.openFileEx()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(171)

本文整理了Java中org.apache.jena.atlas.io.IO.openFileEx()方法的一些代码示例,展示了IO.openFileEx()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IO.openFileEx()方法的具体详情如下:
包路径:org.apache.jena.atlas.io.IO
类名称:IO
方法名:openFileEx

IO.openFileEx介绍

[英]Open an input stream to a file; do not mask IOExceptions. If the filename is null or "-", return System.in If the filename ends in .gz, wrap in GZIPInputStream
[中]打开文件的输入流;不要掩盖异常。如果文件名为null或“-”,则返回System。如果文件名以结尾,则为。gz,用GZIPInputStream包装

代码示例

代码示例来源:origin: apache/jena

  1. /** Open an input stream to a file.
  2. * If the filename is null or "-", return System.in
  3. * If the filename ends in .gz, wrap in GZIPInputStream
  4. */
  5. static public InputStream openFile(String filename) {
  6. try { return openFileEx(filename) ; }
  7. catch (IOException ex) { IO.exception(ex); return null ; }
  8. }

代码示例来源:origin: org.apache.jena/jena-base

  1. /** Open an input stream to a file.
  2. * If the filename is null or "-", return System.in
  3. * If the filename ends in .gz, wrap in GZIPInputStream
  4. */
  5. static public InputStream openFile(String filename) {
  6. try { return openFileEx(filename) ; }
  7. catch (IOException ex) { IO.exception(ex); return null ; }
  8. }

代码示例来源:origin: apache/jena

  1. /**
  2. * Open an input stream to a file and buffer it. If the filename is null or "-",
  3. * return System.in If the filename ends in .gz, wrap in GZIPInputStream.
  4. * If using this {@code InputStream} with an {@code InputStreamReader}
  5. * (e.g. to get UTF-8), there is no need to buffer the {@code InputStream}.
  6. * Instead, buffer the {@code Reader}.
  7. */
  8. static public InputStream openFileBuffered(String filename) {
  9. try {
  10. InputStream in = openFileEx(filename) ;
  11. return new BufferedInputStream(in, BUFFER_SIZE) ;
  12. } catch (IOException ex) { IO.exception(ex); return null ; }
  13. }

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

  1. /** Open an input stream to a file.
  2. * If the filename is null or "-", return System.in
  3. * If the filename ends in .gz, wrap in GZIPInputStream
  4. */
  5. static public InputStream openFile(String filename)
  6. {
  7. try {
  8. return openFileEx(filename) ;
  9. }
  10. catch (Exception ex) { throw new AtlasException(ex) ; }
  11. }

代码示例来源:origin: org.apache.jena/jena-base

  1. /**
  2. * Open an input stream to a file and buffer it. If the filename is null or "-",
  3. * return System.in If the filename ends in .gz, wrap in GZIPInputStream.
  4. * If using this {@code InputStream} with an {@code InputStreamReader}
  5. * (e.g. to get UTF-8), there is no need to buffer the {@code InputStream}.
  6. * Instead, buffer the {@code Reader}.
  7. */
  8. static public InputStream openFileBuffered(String filename) {
  9. try {
  10. InputStream in = openFileEx(filename) ;
  11. return new BufferedInputStream(in, BUFFER_SIZE) ;
  12. } catch (IOException ex) { IO.exception(ex); return null ; }
  13. }

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

  1. /** Read a JSON object from a file */
  2. public static JsonObject read(String filename)
  3. {
  4. try
  5. {
  6. InputStream in = IO.openFileEx(filename) ;
  7. try { return JSON.parse(in) ; } finally { in.close() ; }
  8. }
  9. catch (FileNotFoundException ex)
  10. {
  11. throw new RuntimeException("File not found: "+filename, ex) ;
  12. }
  13. catch (IOException ex)
  14. {
  15. IO.exception("IOException: "+filename, ex);
  16. return null ;
  17. }
  18. }

代码示例来源:origin: apache/jena

  1. /** Read any JSON value, not just an object, from a file */
  2. public static JsonValue readAny(String filename) {
  3. try {
  4. try (InputStream in = IO.openFileEx(filename)) {
  5. return JSON.parseAny(in) ;
  6. }
  7. }
  8. catch (FileNotFoundException ex) {
  9. throw new RuntimeException("File not found: " + filename, ex) ;
  10. }
  11. catch (IOException ex) {
  12. IO.exception("IOException: " + filename, ex) ;
  13. return null ;
  14. }
  15. }

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

  1. /** Read any JSON value, not just an object, from a file */
  2. public static JsonValue readAny(String filename)
  3. {
  4. try
  5. {
  6. InputStream in = IO.openFileEx(filename) ;
  7. try { return JSON.parseAny(in) ; } finally { in.close() ; }
  8. }
  9. catch (FileNotFoundException ex)
  10. {
  11. throw new RuntimeException("File not found: "+filename, ex) ;
  12. }
  13. catch (IOException ex)
  14. {
  15. IO.exception("IOException: "+filename, ex);
  16. return null ;
  17. }
  18. }

代码示例来源:origin: apache/jena

  1. InputStream in = IO.openFileEx(fn) ;

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

  1. InputStream in = IO.openFileEx(fn) ;

代码示例来源:origin: apache/jena

  1. /** Read a JSON object from a file */
  2. public static JsonObject read(String filename) {
  3. try (InputStream in = IO.openFileEx(filename)) {
  4. return JSON.parse(in) ;
  5. }
  6. catch (FileNotFoundException ex) {
  7. IO.exception("File not found: " + filename, ex) ;
  8. return null ;
  9. }
  10. catch (IOException ex) {
  11. IO.exception("IOException: " + filename, ex) ;
  12. return null ;
  13. }
  14. }

代码示例来源:origin: apache/jena

  1. /**
  2. * Read from a file if possible.
  3. * Return null if the file is not found or has a syntax error.
  4. */
  5. public static StoreParams read(String filename) {
  6. try {
  7. InputStream in = IO.openFileEx(filename);
  8. if ( in == null )
  9. return null;
  10. JsonObject obj = JSON.parse(in) ;
  11. return StoreParamsCodec.decode(obj) ;
  12. } catch (FileNotFoundException ex) {
  13. return null;
  14. } catch (JsonParseException ex) {
  15. FmtLog.warn(StoreParamsCodec.class, "Ignoring store params : Syntax error in '%s': [line:%d, col:%d] %s", filename, ex.getLine(), ex.getColumn(), ex.getMessage());
  16. return null ;
  17. } catch (IOException e) {
  18. IO.exception(e);
  19. return null;
  20. }
  21. }

代码示例来源:origin: apache/jena

  1. /**
  2. * Read from a file if possible.
  3. * Return null if the file is not found or has a syntax error.
  4. */
  5. public static StoreParams read(String filename) {
  6. try {
  7. InputStream in = IO.openFileEx(filename);
  8. if ( in == null )
  9. return null;
  10. JsonObject obj = JSON.parse(in) ;
  11. return StoreParamsCodec.decode(obj) ;
  12. } catch (FileNotFoundException ex) {
  13. return null;
  14. } catch (JsonParseException ex) {
  15. FmtLog.warn(StoreParamsCodec.class, "Ignoring store params : Syntax error in '%s': [line:%d, col:%d] %s", filename, ex.getLine(), ex.getColumn(), ex.getMessage());
  16. return null ;
  17. } catch (IOException e) {
  18. IO.exception(e);
  19. return null;
  20. }
  21. }

相关文章