com.sun.enterprise.util.io.FileUtils.copy()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(192)

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

FileUtils.copy介绍

[英]Copies a file.
[中]复制一个文件。

代码示例

代码示例来源:origin: org.glassfish.main.admin/admin-util

@Override
public Object toInstance(InputStream stream, Class clazz) throws IOException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  FileUtils.copy(stream, baos, 0);
  return baos.toByteArray();
}

代码示例来源:origin: org.glassfish.webservices/jsr109-impl

public static void moveFile(String sourceFile, String destFile)
throws IOException {
  FileUtils.copy(sourceFile, destFile);
  new File(sourceFile).delete();
}

代码示例来源:origin: org.glassfish.main.admin/admin-util

@Override
public Object toInstance(InputStream stream, Class clazz) throws IOException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  FileUtils.copy(stream, baos, 0);
  return new String(baos.toByteArray(), charset);
}

代码示例来源:origin: org.glassfish.common/common-util

/**
 * Copies a file.
 *
 * @param from Name of file to copy
 * @param to   Name of new file
 * @throws IOException if an error while copying the content
 */
public static void copy(String from, String to) throws IOException {
  //if(!StringUtils.ok(from) || !StringUtils.ok(to))
  if (from == null || to == null)
    throw new IllegalArgumentException("null or empty filename argument");
  File fin = new File(from);
  File fout = new File(to);
  copy(fin, fout);
}

代码示例来源:origin: org.glassfish.main.common/common-util

/**
 * Copies a file.
 *
 * @param from Name of file to copy
 * @param to   Name of new file
 * @throws IOException if an error while copying the content
 */
public static void copy(String from, String to) throws IOException {
  //if(!StringUtils.ok(from) || !StringUtils.ok(to))
  if (from == null || to == null)
    throw new IllegalArgumentException("null or empty filename argument");
  File fin = new File(from);
  File fout = new File(to);
  copy(fin, fout);
}

代码示例来源:origin: org.glassfish.main.virtualization/virt-core

public boolean download(File remoteFile, File localTargetDirectory) {
    try {
      FileUtils.copy(remoteFile, new File(localTargetDirectory, remoteFile.getName()));
      logger.log(Level.INFO, "Successfully copied file {0} to directory {2}",
          new Object[]{remoteFile.getAbsolutePath(), localTargetDirectory.getAbsolutePath()});
      return true;
    } catch (Exception e) {
      RuntimeContext.logger.log(Level.WARNING, e.getMessage(), e);
      return false;
    }
  }
}

代码示例来源:origin: org.glassfish.main.virtualization/virt-core

public boolean upload(File localFile, File remoteTargetDirectory) {
  try {
    File toFile = new File(remoteTargetDirectory, localFile.getName());
    if(!toFile.equals(localFile)) {
      FileUtils.copy(localFile, toFile);
      logger.log(Level.INFO, "Successfully copied file {0} to directory {1}",
          new Object[]{localFile.getAbsolutePath(), remoteTargetDirectory.getAbsolutePath()});
    }
    return true;
  } catch (Exception e) {
    RuntimeContext.logger.log(Level.WARNING, e.getMessage(), e);
    return false;
  }
}

代码示例来源:origin: org.glassfish.main.common/common-util

/**
 * This method is used to copy a given file to another file
 * using the buffer sixe specified
 *
 * @param fin  the source file
 * @param fout the destination file
 */
public static void copyFile(File fin, File fout) throws IOException {
  InputStream inStream = new BufferedInputStream(new FileInputStream(fin));
  FileOutputStream fos = FileUtils.openFileOutputStream(fout);
  copy(inStream, fos, fin.length());
}

代码示例来源:origin: org.glassfish.common/common-util

/**
 * This method is used to copy a given file to another file
 * using the buffer sixe specified
 *
 * @param fin  the source file
 * @param fout the destination file
 */
public static void copyFile(File fin, File fout) throws IOException {
  InputStream inStream = new BufferedInputStream(new FileInputStream(fin));
  FileOutputStream fos = FileUtils.openFileOutputStream(fout);
  copy(inStream, fos, fin.length());
}

代码示例来源:origin: org.glassfish.main.admin/admin-util

private void handleResponse(ParameterMap params,
    InputStream in, int code, OutputStream userOut)
    throws IOException, CommandException {
  if (userOut == null) {
    handleResponse(params, in, code);
  } else {
    FileUtils.copy(in, userOut, 0);
  }
}

代码示例来源:origin: org.glassfish.admin/admin-util

private void handleResponse(ParameterMap params,
    InputStream in, int code, OutputStream userOut)
    throws IOException, CommandException {
  if (userOut == null) {
    handleResponse(params, in, code);
  } else {
    FileUtils.copy(in, userOut, 0);
  }
}

代码示例来源:origin: eclipse-ee4j/glassfish

/**
 * This method is used to copy a given file to another file
 * using the buffer sixe specified
 *
 * @param fin  the source file
 * @param fout the destination file
 */
public static void copyFile(File fin, File fout) throws IOException {
  InputStream inStream = new BufferedInputStream(new FileInputStream(fin));
  FileOutputStream fos = FileUtils.openFileOutputStream(fout);
  copy(inStream, fos, fin.length());
}

代码示例来源:origin: org.glassfish.common/common-util

public boolean copyLoggingPropertiesFile(File targetDir) throws IOException {
  Logger.getAnonymousLogger().log(Level.WARNING, "Logging.properties file not found, creating new file using DAS logging.properties");
  String rootFolder = env.getProps().get(com.sun.enterprise.util.SystemPropertyConstants.INSTALL_ROOT_PROPERTY);
  String templateDir = rootFolder + File.separator + "lib" + File.separator + "templates";
  File src = new File(templateDir, ServerEnvironmentImpl.kLoggingPropertiesFileName);
  File dest = new File(targetDir, ServerEnvironmentImpl.kLoggingPropertiesFileName);
  try {
    FileUtils.copy(src, dest);
    return true;
  } catch (IOException e) {
    Logger.getAnonymousLogger().log(Level.SEVERE, "Cannot create logging.properties file : ", e);
    throw new IOException();
  }
}

代码示例来源:origin: org.glassfish.main.admin/admin-util

@Override
public AdminCommandState readFrom(final InputStream is, final String contentType) throws IOException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  FileUtils.copy(is, baos, 0);
  String str = baos.toString("UTF-8");
  try {
    JSONObject json = new JSONObject(str);
    return readAdminCommandState(json);
  } catch (JSONException ex) {
    LoggerRef.logger.log(Level.SEVERE, AdminLoggerInfo.mUnexpectedException, ex);
    throw new IOException(ex);
  }
}

代码示例来源:origin: org.glassfish.main.virtualization/virt-core

@Override
public void copy(File source, File destDir) throws IOException {
  FileUtils.copy(absolutize(source), new File(absolutize(destDir), source.getName()));
}

代码示例来源:origin: org.glassfish.main.admin/admin-util

@Override
public ActionReport readFrom(final InputStream is, final String contentType) throws IOException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  FileUtils.copy(is, baos, 0);
  String str = baos.toString("UTF-8");
  try {
    JSONObject json = new JSONObject(str);
    //JSONObject jsonObject = json.getJSONObject("action-report");
    CliActionReport result = new CliActionReport();
    fillActionReport(result, json);
    return result;
  } catch (JSONException ex) {
    LoggerRef.logger.log(Level.SEVERE, AdminLoggerInfo.mUnexpectedException, ex);
    throw new IOException(ex);
  }
}

代码示例来源:origin: org.glassfish.main.admin/server-mgmt

/**
 * Create the timer database dbn file.
 */
protected void createTimerDbn(
    RepositoryConfig config) throws RepositoryException {
  final PEFileLayout layout = getFileLayout(config);
  final File src = layout.getTimerDbnTemplate();
  final File dest = layout.getTimerDbn();
  try {
    FileUtils.copy(src, dest);
  }
  catch (IOException ioe) {
    throw new RepositoryException(
        _strMgr.getString("timerDbnNotCreated"), ioe);
  }
}

代码示例来源:origin: org.glassfish.main.admin/server-mgmt

/**
 * This method is used to create Java EESE install root
 *
 * @param layout PEFileLayout
 */
public void createJavaEESEInstallRoot(PEFileLayout layout)
    throws Exception {
  FileUtils.copy(
      layout.getJavaEESEArchiveSource(),
      layout.getJavaEESEArchiveDestination());
  ZipFile zf = new ZipFile(layout.getJavaEESEArchiveSource(), layout.getJavaEESEInstallRoot());
  zf.explode();
}

代码示例来源:origin: org.glassfish.main.admin/server-mgmt

/**
 * This method is used to create httpsoapbc install root
 *
 * @param layout PEFileLayout
 */
public void createHttpBCInstallRoot(PEFileLayout layout)
    throws Exception {
  FileUtils.copy(
      layout.getHttpBcArchiveSource(),
      layout.getHttpBcArchiveDestination());
  ZipFile zf = new ZipFile(layout.getHttpBcArchiveSource(), layout.getHttpBcInstallRoot());
  zf.explode();
}

代码示例来源:origin: org.glassfish.main.admin/server-mgmt

/**
 * This method is used to create WSDLSL install root
 *
 * @param layout PEFileLayout
 */
public void createWSDLSLInstallRoot(PEFileLayout layout)
    throws Exception {
  FileUtils.copy(
      layout.getWSDLSLArchiveSource(),
      layout.getWSDLSLArchiveDestination());
  ZipFile zf = new ZipFile(layout.getWSDLSLArchiveSource(), layout.getWSDLSLInstallRoot());
  zf.explode();
}

相关文章