提交 cf3bbc5d 编写于 作者: K kohsuke

added more convenience methods

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@16238 71c3de6d-444a-0410-be80-ed276b4c234a
上级 86548f18
......@@ -37,15 +37,12 @@ import hudson.remoting.VirtualChannel;
import hudson.remoting.RemoteInputStream;
import hudson.util.FormFieldValidator;
import hudson.util.IOException2;
import hudson.util.StreamResource;
import hudson.util.HeadBufferingStream;
import hudson.util.jna.GNUCLibrary;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.taskdefs.Copy;
import org.apache.tools.ant.taskdefs.Untar;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.tar.TarEntry;
import org.apache.tools.tar.TarOutputStream;
......@@ -71,6 +68,7 @@ import java.io.Serializable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
......@@ -454,6 +452,35 @@ public final class FilePath implements Serializable {
}
}
/**
* Reads the URL on the current VM, and writes all the data to this {@link FilePath}
* (this is different from resolving URL remotely.)
*
* @since 1.293
*/
public void copyFrom(URL url) throws IOException, InterruptedException {
InputStream in = url.openStream();
try {
copyFrom(in);
} finally {
in.close();
}
}
/**
* Replaces the content of this file by the data from the given {@link InputStream}.
*
* @since 1.293
*/
public void copyFrom(InputStream in) throws IOException, InterruptedException {
OutputStream os = write();
try {
IOUtils.copy(in, os);
} finally {
os.close();
}
}
/**
* Place the data from {@link FileItem} into the file location specified by this {@link FilePath} object.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册