本文整理了Java中org.eclipse.jetty.util.IO.copy()
方法的一些代码示例,展示了IO.copy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IO.copy()
方法的具体详情如下:
包路径:org.eclipse.jetty.util.IO
类名称:IO
方法名:copy
[英]Copy files or directories
[中]复制文件或目录
代码示例来源:origin: org.eclipse.jetty/jetty-util
/** Copy Reader to Writer out until EOF or exception.
* @param in the read to read from (until EOF)
* @param out the writer to write to
* @throws IOException if unable to copy the streams
*/
public static void copy(Reader in, Writer out)
throws IOException
{
copy(in,out,-1);
}
代码示例来源:origin: org.eclipse.jetty/jetty-util
@Override
public void copyTo(File destination)
throws IOException
{
if (isDirectory())
{
IO.copyDir(getFile(),destination);
}
else
{
if (destination.exists())
throw new IllegalArgumentException(destination+" exists");
IO.copy(getFile(),destination);
}
}
代码示例来源:origin: org.eclipse.jetty/jetty-util
/** Copy Stream in to Stream out until EOF or exception.
* @param in the input stream to read from (until EOF)
* @param out the output stream to write to
* @throws IOException if unable to copy streams
*/
public static void copy(InputStream in, OutputStream out)
throws IOException
{
copy(in,out,-1);
}
代码示例来源:origin: org.eclipse.jetty/jetty-util
/** Read input stream to string.
* @param in the reader to read from (until EOF)
* @return the String parsed from the reader
* @throws IOException if unable to read the stream (or handle the charset)
*/
public static String toString(Reader in)
throws IOException
{
StringWriter writer=new StringWriter();
copy(in,writer);
return writer.toString();
}
代码示例来源:origin: org.eclipse.jetty/jetty-util
public static void copyFile(File from,File to) throws IOException
{
try (InputStream in=new FileInputStream(from);
OutputStream out=new FileOutputStream(to))
{
copy(in,out);
}
}
代码示例来源:origin: org.eclipse.jetty/jetty-util
public static byte[] readBytes(InputStream in)
throws IOException
{
ByteArrayOutputStream bout = new ByteArrayOutputStream();
copy(in,bout);
return bout.toByteArray();
}
代码示例来源:origin: org.eclipse.jetty/jetty-util
/** Read input stream to string.
* @param in the stream to read from (until EOF)
* @param encoding the Charset to use (can be null to use default Charset)
* @return the String parsed from the stream
* @throws IOException if unable to read the stream (or handle the charset)
*/
public static String toString(InputStream in, Charset encoding)
throws IOException
{
StringWriter writer=new StringWriter();
InputStreamReader reader = encoding==null?new InputStreamReader(in):new InputStreamReader(in,encoding);
copy(reader,writer);
return writer.toString();
}
代码示例来源:origin: org.eclipse.jetty/jetty-util
/**
* @param out the output stream to write to
* @param start First byte to write
* @param count Bytes to write or -1 for all of them.
* @throws IOException if unable to copy the Resource to the output
*/
public void writeTo(OutputStream out,long start,long count)
throws IOException
{
try (InputStream in = getInputStream())
{
in.skip(start);
if (count<0)
IO.copy(in,out);
else
IO.copy(in,out,count);
}
}
代码示例来源:origin: org.eclipse.jetty/jetty-util
public static void decodeUtf16To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys) throws IOException
{
InputStreamReader input = new InputStreamReader(in,StandardCharsets.UTF_16);
StringWriter buf = new StringWriter(8192);
IO.copy(input,buf,maxLength);
// TODO implement maxKeys
decodeTo(buf.getBuffer().toString(),map,StandardCharsets.UTF_16);
}
代码示例来源:origin: org.eclipse.jetty/jetty-util
public static void copyDir(File from,File to) throws IOException
{
if (to.exists())
{
if (!to.isDirectory())
throw new IllegalArgumentException(to.toString());
}
else
to.mkdirs();
File[] files = from.listFiles();
if (files!=null)
{
for (int i=0;i<files.length;i++)
{
String name = files[i].getName();
if (".".equals(name) || "..".equals(name))
continue;
copy(files[i],new File(to,name));
}
}
}
代码示例来源:origin: org.eclipse.jetty/jetty-util
@Override
public void run()
{
try {
if (in!=null)
copy(in,out,-1);
else
copy(read,write,-1);
}
catch(IOException e)
{
LOG.ignore(e);
try{
if (out!=null)
out.close();
if (write!=null)
write.close();
}
catch(IOException e2)
{
LOG.ignore(e2);
}
}
}
}
代码示例来源:origin: org.eclipse.jetty/jetty-security
private Path extractPackedFile(JarFileResource configResource) throws IOException
{
String uri = configResource.getURI().toASCIIString();
int colon = uri.lastIndexOf(":");
int bang_slash = uri.indexOf("!/");
if (colon < 0 || bang_slash < 0 || colon > bang_slash)
throw new IllegalArgumentException("Not resolved JarFile resource: " + uri);
String entry_path = uri.substring(colon + 2).replace("!/", "__").replace('/', '_').replace('.', '_');
Path tmpDirectory = Files.createTempDirectory("users_store");
tmpDirectory.toFile().deleteOnExit();
Path extractedPath = Paths.get(tmpDirectory.toString(), entry_path);
Files.deleteIfExists(extractedPath);
extractedPath.toFile().deleteOnExit();
IO.copy(configResource.getInputStream(), new FileOutputStream(extractedPath.toFile()));
if (isHotReload())
{
LOG.warn("Cannot hot reload from packed configuration: {}", configResource);
setHotReload(false);
}
return extractedPath;
}
代码示例来源:origin: org.eclipse.jetty/jetty-util
IO.copy(jin,fout);
代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9
/** Copy Stream in to Stream out until EOF or exception.
*/
public static void copy(InputStream in, OutputStream out)
throws IOException
{
copy(in,out,-1);
}
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
/** Copy Stream in to Stream out until EOF or exception.
*/
public static void copy(InputStream in, OutputStream out)
throws IOException
{
copy(in,out,-1);
}
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
/** Read input stream to string.
*/
public static String toString(Reader in)
throws IOException
{
StringWriter writer=new StringWriter();
copy(in,writer);
return writer.toString();
}
代码示例来源:origin: Nextdoor/bender
public static void copyFile(File from,File to) throws IOException
{
try (InputStream in=new FileInputStream(from);
OutputStream out=new FileOutputStream(to))
{
copy(in,out);
}
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-webapp
public static void copyFile(File from,File to) throws IOException
{
FileInputStream in=new FileInputStream(from);
FileOutputStream out=new FileOutputStream(to);
copy(in,out);
in.close();
out.close();
}
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
/** Read input stream to string.
*/
public static String toString(InputStream in,String encoding)
throws IOException
{
StringWriter writer=new StringWriter();
InputStreamReader reader = encoding==null?new InputStreamReader(in):new InputStreamReader(in,encoding);
copy(reader,writer);
return writer.toString();
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-server
public static void decodeUtf16To(InputStream in, MultiMap map, int maxLength, int maxKeys) throws IOException
{
InputStreamReader input = new InputStreamReader(in,StringUtil.__UTF16);
StringWriter buf = new StringWriter(8192);
IO.copy(input,buf,maxLength);
decodeTo(buf.getBuffer().toString(),map,StringUtil.__UTF16,maxKeys);
}
内容来源于网络,如有侵权,请联系作者删除!