hudson.util.IOUtils.closeQuietly()方法的使用及代码示例

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

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

IOUtils.closeQuietly介绍

暂无

代码示例

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

public static void copy(File src, OutputStream out) throws IOException {
  FileInputStream in = new FileInputStream(src);
  try {
    copy(in,out);
  } finally {
    closeQuietly(in);
  }
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

public static void copy(InputStream in, File out) throws IOException {
  FileOutputStream fos = new FileOutputStream(out);
  try {
    copy(in,fos);
  } finally {
    closeQuietly(fos);
  }
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

public static void copy(File src, OutputStream out) throws IOException {
  FileInputStream in = new FileInputStream(src);
  try {
    copy(in, out);
  } finally {
    closeQuietly(in);
  }
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

public static void copy(File src, OutputStream out) throws IOException {
  FileInputStream in = new FileInputStream(src);
  try {
    copy(in,out);
  } finally {
    closeQuietly(in);
  }
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

public Void invoke(File f, VirtualChannel channel) throws IOException {
    f.getParentFile().mkdirs();
    FileOutputStream fos = new FileOutputStream(f);
    Writer w;
    if (encoding != null) {
      w = new OutputStreamWriter(fos, encoding);
    } else {
      w = new OutputStreamWriter(fos);
    }
    try {
      w.write(content);
    } finally {
      IOUtils.closeQuietly(w);
    }
    return null;
  }
});

代码示例来源:origin: org.eclipse.hudson/hudson-core

public static void copy(InputStream in, File out) throws IOException {
  FileOutputStream fos = new FileOutputStream(out);
  try {
    copy(in, fos);
  } finally {
    closeQuietly(fos);
  }
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

public static void copy(InputStream in, File out) throws IOException {
  FileOutputStream fos = new FileOutputStream(out);
  try {
    copy(in,fos);
  } finally {
    closeQuietly(fos);
  }
}

代码示例来源:origin: hudson/hudson-2.x

public static void copy(File src, OutputStream out) throws IOException {
  FileInputStream in = new FileInputStream(src);
  try {
    copy(in,out);
  } finally {
    closeQuietly(in);
  }
}

代码示例来源:origin: hudson/hudson-2.x

public static void copy(InputStream in, File out) throws IOException {
  FileOutputStream fos = new FileOutputStream(out);
  try {
    copy(in,fos);
  } finally {
    closeQuietly(fos);
  }
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

protected final boolean createEmptyChangeLog(File changelogFile, BuildListener listener, String rootTag) {
  FileWriter w = null;
  try {
    w = new FileWriter(changelogFile);
    w.write("<" + rootTag + "/>");
    w.close();
    return true;
  } catch (IOException e) {
    e.printStackTrace(listener.error(e.getMessage()));
    return false;
  } finally {
    IOUtils.closeQuietly(w);
  }
}

代码示例来源:origin: hudson/hudson-2.x

public Void call() throws IOException {
    FileInputStream fis=null;
    try {
      fis = new FileInputStream(new File(remote));
      Util.copyStream(fis,p.getOut());
      return null;
    } finally {
      IOUtils.closeQuietly(fis);
      IOUtils.closeQuietly(p.getOut());
    }
  }
});

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

public Void call() throws IOException {
    FileInputStream fis=null;
    try {
      fis = new FileInputStream(new File(remote));
      Util.copyStream(fis,p.getOut());
      return null;
    } finally {
      IOUtils.closeQuietly(fis);
      IOUtils.closeQuietly(p.getOut());
    }
  }
});

代码示例来源:origin: org.eclipse.hudson/hudson-core

public Void call() throws IOException {
    FileInputStream fis = null;
    try {
      fis = new FileInputStream(new File(remote));
      Util.copyStream(fis, p.getOut());
      return null;
    } finally {
      IOUtils.closeQuietly(fis);
      IOUtils.closeQuietly(p.getOut());
    }
  }
});

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

public Void call() throws IOException {
    FileInputStream fis=null;
    try {
      fis = new FileInputStream(new File(remote));
      Util.copyStream(fis,p.getOut());
      return null;
    } finally {
      IOUtils.closeQuietly(fis);
      IOUtils.closeQuietly(p.getOut());
    }
  }
});

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

private int readSmbFile(SmbFile f) throws IOException {
  InputStream in=null;
  try {
    in = f.getInputStream();
    return Integer.parseInt(IOUtils.toString(in));
  } finally {
    IOUtils.closeQuietly(in);
  }
}

代码示例来源:origin: hudson/hudson-2.x

private int readSmbFile(SmbFile f) throws IOException {
  InputStream in=null;
  try {
    in = f.getInputStream();
    return Integer.parseInt(IOUtils.toString(in));
  } finally {
    IOUtils.closeQuietly(in);
  }
}

代码示例来源:origin: org.jenkins-ci.plugins/credentials

/**
 * {@inheritDoc}
 */
@NonNull
@Override
public byte[] getKeyStoreBytes() {
  try {
    InputStream inputStream = new FileInputStream(new File(keyStoreFile));
    try {
      return IOUtils.toByteArray(inputStream);
    } finally {
      IOUtils.closeQuietly(inputStream);
    }
  } catch (IOException e) {
    LOGGER.log(Level.WARNING, "Could not read private key file " + keyStoreFile, e);
    return new byte[0];
  }
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * Overwrites the file by the given string.
 */
public void write(String text) throws IOException {
  file.getParentFile().mkdirs();
  AtomicFileWriter w = new AtomicFileWriter(file);
  try {
    w.write(text);
    w.commit();
  } finally {
    w.abort();
    IOUtils.closeQuietly(w);
  }
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

public Integer invoke(File f, VirtualChannel channel) throws IOException {
  Archiver a = factory.create(out);
  try {
    scanner.scan(f, a);
  } finally {
    IOUtils.closeQuietly(a);
  }
  return a.countEntries();
}
private static final long serialVersionUID = 1L;

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * Sends out the raw polling log output.
 */
public void doPollingLog(StaplerRequest req, StaplerResponse rsp) throws IOException {
  rsp.setContentType("text/plain;charset=UTF-8");
  // Prevent jelly from flushing stream so Content-Length header can be added afterwards
  FlushProofOutputStream out = null;
  try {
    out = new FlushProofOutputStream(rsp.getCompressedOutputStream(req));
    getPollingLogText().writeLogTo(0, out);
  } finally {
    IOUtils.closeQuietly(out);
  }
}

相关文章