org.xipki.util.IoUtil类的使用及代码示例

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

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

IoUtil介绍

[英]TODO.
[中]待办事项。

代码示例

代码示例来源:origin: xipki/xipki

public byte[] readContent() throws IOException {
 if (binary != null) {
  return binary;
 }
 return IoUtil.read(file);
}

代码示例来源:origin: org.xipki/ca-mgmt-client

public ImportOcspFromCaDb(DataSourceFactory datasourceFactory,
  PasswordResolver passwordResolver, String dbConfFile, String publisherName,
  boolean resume, String srcFolder, int batchEntriesPerCommit, boolean evaluateOnly)
  throws PasswordResolverException, IOException {
 super(datasourceFactory, passwordResolver, dbConfFile);
 this.publisherName = publisherName;
 this.resume = resume;
 this.srcFolder = IoUtil.expandFilepath(srcFolder);
 this.batchEntriesPerCommit = batchEntriesPerCommit;
}

代码示例来源:origin: xipki/xipki

public static void save(String fileName, byte[] encoded) throws IOException {
 save(new File(expandFilepath(fileName)), encoded);
}

代码示例来源:origin: xipki/xipki

public static void save(File file, byte[] content) throws IOException {
 File tmpFile = expandFilepath(file);
 mkdirsParent(tmpFile.toPath());
 Files.copy(new ByteArrayInputStream(content), tmpFile.toPath(),
   StandardCopyOption.REPLACE_EXISTING);
}

代码示例来源:origin: org.xipki/cmpclient

private byte[] send(byte[] request) throws IOException {
 Args.notNull(request, "request");
 HttpURLConnection httpUrlConnection = IoUtil.openHttpConn(serverUrl);
 if (httpUrlConnection instanceof HttpsURLConnection) {
  if (sslSocketFactory != null) {
 return IoUtil.read(inputStream);

代码示例来源:origin: org.xipki/ca-server

public CaManagerImpl() {
 this.datasourceFactory = new DataSourceFactory();
 String calockId = null;
 File caLockFile = new File("calock");
 if (caLockFile.exists()) {
  try {
   calockId = new String(IoUtil.read(caLockFile));
  } catch (IOException ex) {
   LOG.error("could not read {}: {}", caLockFile.getName(), ex.getMessage());
  }
 }
 if (calockId == null) {
  calockId = UUID.randomUUID().toString();
  try {
   IoUtil.save(caLockFile, calockId.getBytes());
  } catch (IOException ex) {
   LOG.error("could not save {}: {}", caLockFile.getName(), ex.getMessage());
  }
 }
 String hostAddress = null;
 try {
  hostAddress = IoUtil.getHostAddress();
 } catch (SocketException ex) {
  LOG.warn("could not get host address: {}", ex.getMessage());
 }
 this.lockInstanceId = (hostAddress == null) ? calockId : hostAddress + "/" + calockId;
 this.restResponder = new RestResponder(this);
} // constructor

代码示例来源:origin: org.xipki.shells/ocsp-client-shell

new X509AttributeCertificateHolder(IoUtil.read(certFile));
byte[] encodedCert = IoUtil.read(certFile);
encodedCerts.put(sn, encodedCert);
 byte[] bytes = reqResp.getRequest();
 if (bytes != null) {
  IoUtil.save(reqout, bytes);
 byte[] bytes = reqResp.getResponse();
 if (bytes != null) {
  IoUtil.save(respout, bytes);

代码示例来源:origin: org.xipki/security

private void createExampleRepository(File dir, int numSlots) throws IOException {
 for (int i = 0; i < numSlots; i++) {
  File slotDir = new File(dir, i + "-" + (800000 + i));
  slotDir.mkdirs();
  File slotInfoFile = new File(slotDir, "slot.info");
  IoUtil.save(slotInfoFile, "namedCurveSupported=true\n".getBytes());
 }
}

代码示例来源:origin: org.xipki/ca-mgmt-client

protected FileOrValue buildFileOrValue(String content, String fileName) throws IOException {
 if (content == null) {
  return null;
 }
 Args.notNull(fileName, "fileName");
 FileOrValue ret = new FileOrValue();
 if (content.length() < 256) {
  ret.setValue(content);
  return ret;
 }
 File file = new File(baseDir, fileName);
 IoUtil.mkdirsParent(file.toPath());
 IoUtil.save(file, content.getBytes("UTF-8"));
 ret.setFile(fileName);
 return ret;
}

代码示例来源:origin: org.xipki/security

protected byte[] send(byte[] request) throws IOException {
 Args.notNull(request, "request");
 HttpURLConnection httpUrlConnection = IoUtil.openHttpConn(serverUrl);

代码示例来源:origin: org.xipki.shell/shell-base

@Override
protected Object execute0() throws Exception {
 source = expandFilepath(source);
 dest = expandFilepath(dest);
 File sourceFile = new File(source);
 if (!sourceFile.exists()) {
  throw new IllegalCmdParamException(source + " does not exist");
 }
 if (!sourceFile.isFile()) {
  throw new IllegalCmdParamException(source + " is not a file");
 }
 File destFile = new File(dest);
 if (destFile.exists()) {
  if (!destFile.isFile()) {
   throw new IllegalCmdParamException("cannot override an existing directory by a file");
  } else {
   if (!force.booleanValue() && !confirm("Do you want to override the file " + dest, 3)) {
    return null;
   }
  }
 } else {
  IoUtil.mkdirsParent(destFile.toPath());
 }
 FileUtils.copyFile(sourceFile, destFile, true);
 sourceFile.delete();
 return null;
}

代码示例来源:origin: org.xipki/ocsp-client

httpUrlConnection = IoUtil.openHttpConn(newUrl);
 httpUrlConnection.setRequestMethod("GET");
} else {
 httpUrlConnection = IoUtil.openHttpConn(responderUrl);
 httpUrlConnection.setDoOutput(true);
 httpUrlConnection.setUseCaches(false);
return IoUtil.read(inputstream);

代码示例来源:origin: org.xipki.shell/ocsp-client-shell

new X509AttributeCertificateHolder(IoUtil.read(certFile));
byte[] encodedCert = IoUtil.read(certFile);
encodedCerts.put(sn, encodedCert);
 byte[] bytes = reqResp.getRequest();
 if (bytes != null) {
  IoUtil.save(reqout, bytes);
 byte[] bytes = reqResp.getResponse();
 if (bytes != null) {
  IoUtil.save(respout, bytes);

代码示例来源:origin: org.xipki/ca-dbtool

public DigestDiffReporter(String reportDirname, byte[] caCertBytes) throws IOException {
 this.reportDirname = ParamUtil.requireNonBlank("reportDirname", reportDirname);
 File dir = new File(reportDirname);
 dir.mkdirs();
 IoUtil.save(new File(dir, "ca.der"), caCertBytes);
 this.missingWriter = new BufferedWriter(new FileWriter(new File(dir, "missing")));
 this.unexpectedWriter = new BufferedWriter(new FileWriter(new File(dir, "unexpected")));
 this.diffWriter = new BufferedWriter(new FileWriter(new File(dir, "diff")));
 this.goodWriter = new BufferedWriter(new FileWriter(new File(dir, "good")));
 this.errorWriter = new BufferedWriter(new FileWriter(new File(dir, "error")));
 start();
}

代码示例来源:origin: org.xipki/util

public static void save(File file, byte[] content) throws IOException {
 File tmpFile = expandFilepath(file);
 mkdirsParent(tmpFile.toPath());
 Files.copy(new ByteArrayInputStream(content), tmpFile.toPath(),
   StandardCopyOption.REPLACE_EXISTING);
}

代码示例来源:origin: org.xipki/ca-mgmt-client

protected FileOrBinary buildFileOrBinary(byte[] content, String fileName) throws IOException {
 if (content == null) {
  return null;
 }
 Args.notNull(fileName, "fileName");
 FileOrBinary ret = new FileOrBinary();
 if (content.length < 256) {
  ret.setBinary(content);
  return ret;
 }
 File file = new File(baseDir, fileName);
 IoUtil.mkdirsParent(file.toPath());
 IoUtil.save(file, content);
 ret.setFile(fileName);
 return ret;
}

代码示例来源:origin: org.xipki.shell/shell-base

@Override
protected Object execute0() throws Exception {
 source = expandFilepath(source);
 dest = expandFilepath(dest);
 File sourceFile = new File(source);
 if (!sourceFile.exists()) {
  throw new IllegalCmdParamException(source + " does not exist");
 }
 if (!sourceFile.isFile()) {
  throw new IllegalCmdParamException(source + " is not a file");
 }
 File destFile = new File(dest);
 if (destFile.exists()) {
  if (!destFile.isFile()) {
   throw new IllegalCmdParamException("cannot override an existing directory by a file");
  } else {
   if (!force.booleanValue() && !confirm("Do you want to override the file " + dest, 3)) {
    return null;
   }
  }
 } else {
  IoUtil.mkdirsParent(destFile.toPath());
 }
 FileUtils.copyFile(sourceFile, destFile, true);
 return null;
}

代码示例来源:origin: org.xipki/util

public byte[] readContent() throws IOException {
 if (binary != null) {
  return binary;
 }
 return IoUtil.read(file);
}

代码示例来源:origin: org.xipki/ca-mgmt-client

public ImportCaDb(DataSourceFactory datasourceFactory, PasswordResolver passwordResolver,
  String dbConfFile, boolean resume, String srcFolder, int batchEntriesPerCommit)
  throws PasswordResolverException, IOException {
 super(datasourceFactory, passwordResolver, dbConfFile);
 this.resume = resume;
 this.srcFolder = IoUtil.expandFilepath(srcFolder);
 this.batchEntriesPerCommit = batchEntriesPerCommit;
}

代码示例来源:origin: org.xipki/ca-mgmt-client

HttpURLConnection httpUrlConnection = IoUtil.openHttpConn(url);
  } else {
   inClosed = true;
   return IoUtil.read(httpUrlConnection.getInputStream());

相关文章