org.apache.jena.atlas.lib.Bytes.bytes2string()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(97)

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

Bytes.bytes2string介绍

[英]Return the string for some UTF-8 bytes
[中]返回一些UTF-8字节的字符串

代码示例

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

private void executeBody(HttpAction action) {
  InputStream input = null ;
  try { input = action.request.getInputStream() ; }
  catch (IOException ex) { ServletOps.errorOccurred(ex) ; }
  if ( action.verbose ) {
    // Verbose mode only .... capture request for logging (does not scale).
    byte[] bytes = IO.readWholeFile(input);
    input = new ByteArrayInputStream(bytes);
    try {
      String requestStr = Bytes.bytes2string(bytes) ;
      action.log.info(format("[%d] Update = %s", action.id, ServletOps.formatForLog(requestStr))) ;
    } catch (Exception ex) {
      action.log.info(format("[%d] Update = <failed to decode>", action.id)) ;
    }
  }
  execute(action, input) ;
  ServletOps.successNoContent(action) ;
}

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

private void executeBody(HttpAction action) {
  InputStream input = null ;
  try { input = action.request.getInputStream() ; }
  catch (IOException ex) { ServletOps.errorOccurred(ex) ; }
  if ( action.verbose ) {
    // Verbose mode only .... capture request for logging (does not scale).
    byte[] bytes = IO.readWholeFile(input);
    input = new ByteArrayInputStream(bytes);
    try {
      String requestStr = Bytes.bytes2string(bytes) ;
      action.log.info(format("[%d] Update = %s", action.id, ServletOps.formatForLog(requestStr))) ;
    } catch (Exception ex) {
      action.log.info(format("[%d] Update = <failed to decode>", action.id)) ;
    }
  }
  execute(action, input) ;
  ServletOps.successNoContent(action) ;
}

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

private void test(String filename) {
    Model m = readModel(filename) ;
    ByteArrayOutputStream out2 = new ByteArrayOutputStream() ;
    RDFDataMgr.write(out2, m, RDFWriterRegistry.getFormatForJenaWriter(jenaFormatName)) ;

    ByteArrayOutputStream out1 = new ByteArrayOutputStream() ;
    m.write(out1, jenaFormatName) ;
    
    try {
      assertArrayEquals("Format: "+jenaFormatName, out2.toByteArray(), out1.toByteArray()) ;
    } catch (AssertionError ex) {
      String s1 = Bytes.bytes2string(out1.toByteArray()) ;
      String s2 = Bytes.bytes2string(out2.toByteArray()) ;
      System.out.print(s1) ;
      System.out.print(s2) ;
      throw ex ;
    }
  }
}

相关文章