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

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

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

IO.exception介绍

[英]Throw a RuntimeIOException - this function is guaranteed not to return normally
[中]抛出RuntimeIOException-此函数保证不会正常返回

代码示例

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

  1. @Override
  2. public void flush()
  3. {
  4. try { writer.flush() ; } catch (IOException ex) { IO.exception(ex) ; }
  5. }

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

  1. @Override
  2. public void close()
  3. {
  4. try { writer.close() ; } catch (IOException ex) { IO.exception(ex) ; }
  5. }

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

  1. @Override
  2. public void close()
  3. {
  4. try { reader.close() ; } catch (IOException ex) { IO.exception(ex) ; }
  5. }

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

  1. private void checkPosition(long posn) {
  2. // Allows posn to be exactly the byte beyond the end
  3. if ( posn < 0 || posn > dataLength )
  4. IO.exception(String.format("Position out of bounds: %d in [0,%d]", posn, dataLength)) ;
  5. }

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

  1. @Override
  2. public long position() {
  3. try {
  4. return file.position() ;
  5. }
  6. catch (IOException e) {
  7. IO.exception(e) ;
  8. return -1 ;
  9. }
  10. }

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

  1. @Override
  2. public int read(ByteBuffer buffer, long loc) {
  3. try {
  4. return file.read(buffer, loc) ;
  5. }
  6. catch (IOException e) {
  7. IO.exception(e) ;
  8. return -1 ;
  9. }
  10. }

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

  1. @Override
  2. public int write(ByteBuffer buffer) {
  3. try {
  4. return file.write(buffer) ;
  5. }
  6. catch (IOException e) {
  7. IO.exception(e) ;
  8. return -1 ;
  9. }
  10. }

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

  1. @Override
  2. public void close()
  3. {
  4. try { super.close() ; } catch (IOException ex) { IO.exception(ex) ; }
  5. }
  6. }

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

  1. private void free() {
  2. try {
  3. if ( fileLock != null )
  4. fileLock.release();
  5. fileChannel.close();
  6. fileLock = null;
  7. } catch (IOException ex) { IO.exception(ex); }
  8. }

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

  1. /** Copy a file */
  2. public static void copyFile(File source, File dest) {
  3. try {
  4. Files.copy(source.toPath(), dest.toPath());
  5. }
  6. catch (IOException ex) {
  7. IO.exception(ex) ;
  8. }
  9. }

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

  1. @Override
  2. public void truncate(long length) {
  3. try {
  4. // http://bugs.sun.com/view_bug.do?bug_id=6191269
  5. if ( length < file.position() )
  6. file.position(length) ;
  7. file.truncate(length) ;
  8. }
  9. catch (IOException e) {
  10. IO.exception(e) ;
  11. }
  12. }

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

  1. /** Open a file for output - may include adding gzip processing. */
  2. static public OutputStream openOutputFile(String filename) {
  3. try { return openOutputFileEx(filename) ; }
  4. catch (IOException ex) { IO.exception(ex) ; return null ; }
  5. }

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

  1. @Override
  2. protected ByteBuffer allocateBuffer(long size)
  3. {
  4. try { return file.channel().map(FileChannel.MapMode.READ_WRITE, 0, size) ; }
  5. catch (IOException ex) { IO.exception(ex) ; return null ; }
  6. }
  7. }

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

  1. @Override
  2. public int read(ByteBuffer buffer)
  3. {
  4. try { return file.channel().read(buffer) ; }
  5. catch (IOException e) { IO.exception(e) ; return -1 ; }
  6. }

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

  1. @Override
  2. public int write(ByteBuffer buffer, long loc)
  3. {
  4. try { return file.channel().write(buffer, loc) ; }
  5. catch (IOException e) { IO.exception(e) ; return -1 ; }
  6. }

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

  1. @Override
  2. public boolean isEmpty()
  3. {
  4. try { return file.channel().size() == 0 ; }
  5. catch (IOException e) { IO.exception(e) ; return false ; }
  6. }

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

  1. public void truncate(long length) {
  2. if ( TRACKING )
  3. log("truncate(%d)", length) ;
  4. if ( length < 0 )
  5. IO.exception(String.format("truncate: bad length : %d", length)) ;
  6. checkOpen() ;
  7. dataLength = Math.min(dataLength, length) ;
  8. // clear above?
  9. }

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

  1. @Override
  2. public void close() {
  3. try {
  4. reader.close() ;
  5. }
  6. catch (IOException ex) {
  7. IO.exception(ex) ;
  8. }
  9. }

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

  1. /** Write to a file */
  2. public static void write(String filename, StoreParams params) {
  3. try (OutputStream out = new FileOutputStream(filename);
  4. OutputStream out2 = new BufferedOutputStream(out); ) {
  5. JsonObject object = encodeToJson(params) ;
  6. JSON.write(out2, object) ;
  7. out2.write('\n') ;
  8. }
  9. catch (IOException ex) { IO.exception(ex); }
  10. }

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

  1. /** Create or fetch a {@link ProcessFileLock} for a Location */
  2. public static ProcessFileLock lockForLocation(Location location) {
  3. FileOps.ensureDir(location.getDirectoryPath());
  4. String lockFilename = location.getPath(Names.TDB_LOCK_FILE);
  5. Path path = Paths.get(lockFilename);
  6. try {
  7. path.toFile().createNewFile();
  8. } catch(IOException ex) { IO.exception(ex); return null; }
  9. return ProcessFileLock.create(lockFilename);
  10. }

相关文章