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

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

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

Bytes.string2bytes介绍

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

代码示例

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

@Override
  public Node call() {
    return alloc(Bytes.string2bytes(label));
  }
};

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

@Override
public Node alloc(String label) {
  return alloc(Bytes.string2bytes(label)) ;
}

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

private static InputStream stream(String data)
{
  byte[] b = Bytes.string2bytes(data) ;
  return new ByteArrayInputStream(b) ;
}

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

private static void hash(Hash h, String lex, String lang, String datatype, String nodeName) {
  if ( datatype == null )
    datatype = "";
  if ( lang == null )
    lang = "";
  String toHash = lex + "|" + lang + "|" + datatype + "|" + nodeName;
  MessageDigest digest;
  try {
    // MessageDigest.getInstance("MD5");
    digest = allocDigest();
    digest.update(Bytes.string2bytes(toHash));
    if ( h.getLen() == 16 ) {
      // MD5 is 16 bytes.
      digest.digest(h.getBytes(), 0, 16);
    } else {
      byte b[] = digest.digest(); // 16 bytes.
      System.arraycopy(b, 0, h.getBytes(), 0, h.getLen());
    }
    deallocDigest(digest);
    return;
  }
  catch (DigestException ex) {
    Log.error(NodeLib.class, "DigestException", ex);
  }
}

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

private static void hash(Hash h, String lex, String lang, String datatype, NodeType nodeType) {
  if ( datatype == null )
    datatype = "";
  if ( lang == null )
    lang = "";
  String toHash = lex + "|" + lang + "|" + datatype + "|" + nodeType.getName();
  MessageDigest digest;
  try {
    digest = allocDigest();
    digest.update(Bytes.string2bytes(toHash));
    if ( h.getLen() == 16 )
      // MD5 is 16 bytes.
      digest.digest(h.getBytes(), 0, 16);
    else {
      byte b[] = digest.digest(); // 16 bytes.
      // Avoid the copy if length is 16? 
      // digest.digest(bytes, 0, length) needs 16 bytes
      System.arraycopy(b, 0, h.getBytes(), 0, h.getLen());
    }
    deallocDigest(digest);
    return;
  }
  catch (DigestException ex) {
    Log.error(NodeLib.class, "DigestException", ex);
  }
}

相关文章