Java Code Examples for org.apache.commons.net.util.Base64#encodeBase64String()

The following examples show how to use org.apache.commons.net.util.Base64#encodeBase64String() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DbfsServiceImpl.java    From databricks-rest-client with Apache License 2.0 5 votes vote down vote up
private void addBlocks(InputStream inputStream, long handle)
    throws IOException, DatabricksRestException {
  if (handle != 0L) {
    byte[] buffer = new byte[1024 * 1024];
    int read;
    while ((read = inputStream.read(buffer)) > -1) {
      String data = Base64.encodeBase64String(Arrays.copyOf(buffer, read));
      Map<String, Object> params = new HashMap<>();
      params.put("handle", handle);
      params.put("data", data);
      client.performQuery(RequestMethod.POST, "/dbfs/add-block", params);
    }
    closeHandle(handle);
  }
}
 
Example 2
Source File: Nd4jBase64.java    From nd4j with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a tab delimited base 64
 * representation of the given arrays
 * @param arrays the arrays
 * @return
 * @throws IOException
 */
public static String arraysToBase64(INDArray[] arrays) throws IOException {
    StringBuilder sb = new StringBuilder();
    //tab separate the outputs for de serialization
    for (INDArray outputArr : arrays) {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(bos);
        Nd4j.write(outputArr, dos);
        String base64 = Base64.encodeBase64String(bos.toByteArray());
        sb.append(base64);
        sb.append("\t");
    }

    return sb.toString();
}
 
Example 3
Source File: RecordChecksum.java    From Scribengin with GNU Affero General Public License v3.0 4 votes vote down vote up
public String getKeyDigestAsBase64() { 
  invalidUpdateState = true;
  return Base64.encodeBase64String(keyDigest.digest()); 
}
 
Example 4
Source File: RecordChecksum.java    From Scribengin with GNU Affero General Public License v3.0 4 votes vote down vote up
public String getDataDigestAsBase64() {
  invalidUpdateState = true;
  return Base64.encodeBase64String(dataDigest.digest()); 
}
 
Example 5
Source File: Nd4jBase64.java    From nd4j with Apache License 2.0 3 votes vote down vote up
/**
 * Returns an ndarray
 * as base 64
 * @param arr the array to write
 * @return the base 64 representation of the binary
 * ndarray
 * @throws IOException
 */
public static String base64String(INDArray arr) throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(bos);
    Nd4j.write(arr, dos);
    String base64 = Base64.encodeBase64String(bos.toByteArray());
    return base64;
}
 
Example 6
Source File: Nd4jBase64.java    From deeplearning4j with Apache License 2.0 3 votes vote down vote up
/**
 * Returns an ndarray
 * as base 64
 * @param arr the array to write
 * @return the base 64 representation of the binary
 * ndarray
 */
public static String base64String(INDArray arr) throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(bos);
    Nd4j.write(arr, dos);
    return Base64.encodeBase64String(bos.toByteArray());
}