org.eclipse.jetty.util.IO.copy()方法的使用及代码示例

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

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

IO.copy介绍

[英]Copy files or directories
[中]复制文件或目录

代码示例

代码示例来源:origin: org.eclipse.jetty/jetty-util

  1. /** Copy Reader to Writer out until EOF or exception.
  2. * @param in the read to read from (until EOF)
  3. * @param out the writer to write to
  4. * @throws IOException if unable to copy the streams
  5. */
  6. public static void copy(Reader in, Writer out)
  7. throws IOException
  8. {
  9. copy(in,out,-1);
  10. }

代码示例来源:origin: org.eclipse.jetty/jetty-util

  1. @Override
  2. public void copyTo(File destination)
  3. throws IOException
  4. {
  5. if (isDirectory())
  6. {
  7. IO.copyDir(getFile(),destination);
  8. }
  9. else
  10. {
  11. if (destination.exists())
  12. throw new IllegalArgumentException(destination+" exists");
  13. IO.copy(getFile(),destination);
  14. }
  15. }

代码示例来源:origin: org.eclipse.jetty/jetty-util

  1. /** Copy Stream in to Stream out until EOF or exception.
  2. * @param in the input stream to read from (until EOF)
  3. * @param out the output stream to write to
  4. * @throws IOException if unable to copy streams
  5. */
  6. public static void copy(InputStream in, OutputStream out)
  7. throws IOException
  8. {
  9. copy(in,out,-1);
  10. }

代码示例来源:origin: org.eclipse.jetty/jetty-util

  1. /** Read input stream to string.
  2. * @param in the reader to read from (until EOF)
  3. * @return the String parsed from the reader
  4. * @throws IOException if unable to read the stream (or handle the charset)
  5. */
  6. public static String toString(Reader in)
  7. throws IOException
  8. {
  9. StringWriter writer=new StringWriter();
  10. copy(in,writer);
  11. return writer.toString();
  12. }

代码示例来源:origin: org.eclipse.jetty/jetty-util

  1. public static void copyFile(File from,File to) throws IOException
  2. {
  3. try (InputStream in=new FileInputStream(from);
  4. OutputStream out=new FileOutputStream(to))
  5. {
  6. copy(in,out);
  7. }
  8. }

代码示例来源:origin: org.eclipse.jetty/jetty-util

  1. public static byte[] readBytes(InputStream in)
  2. throws IOException
  3. {
  4. ByteArrayOutputStream bout = new ByteArrayOutputStream();
  5. copy(in,bout);
  6. return bout.toByteArray();
  7. }

代码示例来源:origin: org.eclipse.jetty/jetty-util

  1. /** Read input stream to string.
  2. * @param in the stream to read from (until EOF)
  3. * @param encoding the Charset to use (can be null to use default Charset)
  4. * @return the String parsed from the stream
  5. * @throws IOException if unable to read the stream (or handle the charset)
  6. */
  7. public static String toString(InputStream in, Charset encoding)
  8. throws IOException
  9. {
  10. StringWriter writer=new StringWriter();
  11. InputStreamReader reader = encoding==null?new InputStreamReader(in):new InputStreamReader(in,encoding);
  12. copy(reader,writer);
  13. return writer.toString();
  14. }

代码示例来源:origin: org.eclipse.jetty/jetty-util

  1. /**
  2. * @param out the output stream to write to
  3. * @param start First byte to write
  4. * @param count Bytes to write or -1 for all of them.
  5. * @throws IOException if unable to copy the Resource to the output
  6. */
  7. public void writeTo(OutputStream out,long start,long count)
  8. throws IOException
  9. {
  10. try (InputStream in = getInputStream())
  11. {
  12. in.skip(start);
  13. if (count<0)
  14. IO.copy(in,out);
  15. else
  16. IO.copy(in,out,count);
  17. }
  18. }

代码示例来源:origin: org.eclipse.jetty/jetty-util

  1. public static void decodeUtf16To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys) throws IOException
  2. {
  3. InputStreamReader input = new InputStreamReader(in,StandardCharsets.UTF_16);
  4. StringWriter buf = new StringWriter(8192);
  5. IO.copy(input,buf,maxLength);
  6. // TODO implement maxKeys
  7. decodeTo(buf.getBuffer().toString(),map,StandardCharsets.UTF_16);
  8. }

代码示例来源:origin: org.eclipse.jetty/jetty-util

  1. public static void copyDir(File from,File to) throws IOException
  2. {
  3. if (to.exists())
  4. {
  5. if (!to.isDirectory())
  6. throw new IllegalArgumentException(to.toString());
  7. }
  8. else
  9. to.mkdirs();
  10. File[] files = from.listFiles();
  11. if (files!=null)
  12. {
  13. for (int i=0;i<files.length;i++)
  14. {
  15. String name = files[i].getName();
  16. if (".".equals(name) || "..".equals(name))
  17. continue;
  18. copy(files[i],new File(to,name));
  19. }
  20. }
  21. }

代码示例来源:origin: org.eclipse.jetty/jetty-util

  1. @Override
  2. public void run()
  3. {
  4. try {
  5. if (in!=null)
  6. copy(in,out,-1);
  7. else
  8. copy(read,write,-1);
  9. }
  10. catch(IOException e)
  11. {
  12. LOG.ignore(e);
  13. try{
  14. if (out!=null)
  15. out.close();
  16. if (write!=null)
  17. write.close();
  18. }
  19. catch(IOException e2)
  20. {
  21. LOG.ignore(e2);
  22. }
  23. }
  24. }
  25. }

代码示例来源:origin: org.eclipse.jetty/jetty-security

  1. private Path extractPackedFile(JarFileResource configResource) throws IOException
  2. {
  3. String uri = configResource.getURI().toASCIIString();
  4. int colon = uri.lastIndexOf(":");
  5. int bang_slash = uri.indexOf("!/");
  6. if (colon < 0 || bang_slash < 0 || colon > bang_slash)
  7. throw new IllegalArgumentException("Not resolved JarFile resource: " + uri);
  8. String entry_path = uri.substring(colon + 2).replace("!/", "__").replace('/', '_').replace('.', '_');
  9. Path tmpDirectory = Files.createTempDirectory("users_store");
  10. tmpDirectory.toFile().deleteOnExit();
  11. Path extractedPath = Paths.get(tmpDirectory.toString(), entry_path);
  12. Files.deleteIfExists(extractedPath);
  13. extractedPath.toFile().deleteOnExit();
  14. IO.copy(configResource.getInputStream(), new FileOutputStream(extractedPath.toFile()));
  15. if (isHotReload())
  16. {
  17. LOG.warn("Cannot hot reload from packed configuration: {}", configResource);
  18. setHotReload(false);
  19. }
  20. return extractedPath;
  21. }

代码示例来源:origin: org.eclipse.jetty/jetty-util

  1. IO.copy(jin,fout);

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

  1. /** Copy Stream in to Stream out until EOF or exception.
  2. */
  3. public static void copy(InputStream in, OutputStream out)
  4. throws IOException
  5. {
  6. copy(in,out,-1);
  7. }

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

  1. /** Copy Stream in to Stream out until EOF or exception.
  2. */
  3. public static void copy(InputStream in, OutputStream out)
  4. throws IOException
  5. {
  6. copy(in,out,-1);
  7. }

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

  1. /** Read input stream to string.
  2. */
  3. public static String toString(Reader in)
  4. throws IOException
  5. {
  6. StringWriter writer=new StringWriter();
  7. copy(in,writer);
  8. return writer.toString();
  9. }

代码示例来源:origin: Nextdoor/bender

  1. public static void copyFile(File from,File to) throws IOException
  2. {
  3. try (InputStream in=new FileInputStream(from);
  4. OutputStream out=new FileOutputStream(to))
  5. {
  6. copy(in,out);
  7. }
  8. }

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-webapp

  1. public static void copyFile(File from,File to) throws IOException
  2. {
  3. FileInputStream in=new FileInputStream(from);
  4. FileOutputStream out=new FileOutputStream(to);
  5. copy(in,out);
  6. in.close();
  7. out.close();
  8. }

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

  1. /** Read input stream to string.
  2. */
  3. public static String toString(InputStream in,String encoding)
  4. throws IOException
  5. {
  6. StringWriter writer=new StringWriter();
  7. InputStreamReader reader = encoding==null?new InputStreamReader(in):new InputStreamReader(in,encoding);
  8. copy(reader,writer);
  9. return writer.toString();
  10. }

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-server

  1. public static void decodeUtf16To(InputStream in, MultiMap map, int maxLength, int maxKeys) throws IOException
  2. {
  3. InputStreamReader input = new InputStreamReader(in,StringUtil.__UTF16);
  4. StringWriter buf = new StringWriter(8192);
  5. IO.copy(input,buf,maxLength);
  6. decodeTo(buf.getBuffer().toString(),map,StringUtil.__UTF16,maxKeys);
  7. }

相关文章