org.eclipse.jetty.util.IO类的使用及代码示例

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

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

IO介绍

[英]IO Utilities. Provides stream handling utilities in singleton Threadpool implementation accessed by static members.
[中]IO实用程序。在静态成员访问的singleton Threadpool实现中提供流处理实用程序。

代码示例

代码示例来源: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

/**
 * closes a reader, and logs exceptions
 *
 * @param reader the reader to close
 */
public static void close(Reader reader)
{
  close((Closeable)reader);
}

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

/** Read input stream to string.
 * @param in the stream to read from (until EOF)
 * @return the String parsed from stream (default Charset)
 * @throws IOException if unable to read the stream (or handle the charset)
 */
public static String toString(InputStream in)
  throws IOException
{
  return toString(in,(Charset)null);
}

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

/** Copy files or directories
 * @param from the file to copy
 * @param to the destination to copy to
 * @throws IOException if unable to copy
 */
public static void copy(File from,File to) throws IOException
{
  if (from.isDirectory())
    copyDir(from,to);
  else
    copyFile(from,to);
}

代码示例来源: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-webapp

if (web_app.isAlias())
  LOG.debug(web_app + " anti-aliased to " + web_app.getAlias());
  web_app = context.newResource(web_app.getAlias());
if (LOG.isDebugEnabled())
  LOG.debug("Try webapp=" + web_app + ", exists=" + web_app.exists() + ", directory=" + web_app.isDirectory()+" file="+(web_app.getFile()));
        IO.delete(extractedWebAppDir);
        extractedWebAppDir.mkdir();
        LOG.debug("Extract " + web_app + " to " + extractedWebAppDir);
  IO.delete(extractedWebInfDir);
extractedWebInfDir.mkdir();
Resource web_inf_lib = web_inf.addPath("lib/");
    IO.delete(webInfLibDir);
  webInfLibDir.mkdir();
    IO.delete(webInfClassesDir);
  webInfClassesDir.mkdir();
  LOG.debug("Copying WEB-INF/classes from "+web_inf_classes+" to "+webInfClassesDir.getAbsolutePath());

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

public DefaultHandler()
{
  try
  {
    URL fav = this.getClass().getClassLoader().getResource("org/eclipse/jetty/favicon.ico");
    if (fav!=null)
    {
      Resource r = Resource.newResource(fav);
      _favicon=IO.readBytes(r.getInputStream());
    }
  }
  catch(Exception e)
  {
    LOG.warn(e);
  }
}

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

public void destroy()
{
  for (File file : _files)
  {
    if (file.exists())
    {
      LOG.debug("Destroy {}",file);
      IO.delete(file);
    }
  }
}

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

@Override
public void destroy()
{
  for (File file : _files)
  {
    if (file.exists())
    {
      if (LOG.isDebugEnabled())
        LOG.debug("Destroy {}",file);
      IO.delete(file);
    }
  }
}

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

byte[] bytes = IO.readBytes(content);
if (LOG.isDebugEnabled())
  LOG.debug("foundClass({}) url={} cl={}",name,url,this);

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

return;
if(LOG.isDebugEnabled())
  LOG.debug("Extract "+this+" to "+directory);
boolean subEntryIsDir = (subEntryName != null && subEntryName.endsWith("/")?true:false);
if (LOG.isDebugEnabled()) 
  LOG.debug("Extracting entry = "+subEntryName+" from jar "+jarFileURL);
URLConnection c = jarFileURL.openConnection();
        IO.copy(jin,fout);

代码示例来源: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

@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-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 close() throws IOException {this.in=IO.getClosedStream();}
};

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

@Override
public PrintWriter getWriter() throws IOException
{
  return IO.getNullPrintWriter();
}

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

@Override
public void deconfigure(WebAppContext context) throws Exception
{
  //if we're not persisting the temp dir contents delete it
  if (!context.isPersistTempDirectory())
  {
    IO.delete(context.getTempDirectory());
  }
  
  //if it wasn't explicitly configured by the user, then unset it
  Boolean tmpdirConfigured = (Boolean)context.getAttribute(TEMPDIR_CONFIGURED);
  if (tmpdirConfigured != null && !tmpdirConfigured) 
    context.setTempDirectory(null);
  //reset the base resource back to what it was before we did any unpacking of resources
  if (context.getBaseResource() != null)
    context.getBaseResource().close();
  context.setBaseResource(_preUnpackBaseResource);
}

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

public void configureTempDirectory (File dir, WebAppContext context)
{
  if (dir == null)
    throw new IllegalArgumentException("Null temp dir");
  //if dir exists and we don't want it persisted, delete it
  if (dir.exists() && !context.isPersistTempDirectory())
  {
    if (!IO.delete(dir))
      throw new IllegalStateException("Failed to delete temp dir "+dir);
  }
  //if it doesn't exist make it
  if (!dir.exists())
    dir.mkdirs();
  if (!context.isPersistTempDirectory())
    dir.deleteOnExit();
  //is it useable
  if (!dir.canWrite() || !dir.isDirectory())   
    throw new IllegalStateException("Temp dir "+dir+" not useable: writeable="+dir.canWrite()+", dir="+dir.isDirectory());
}

代码示例来源:origin: cd.connect.common/connect-runnable-war

public InMemoryResource(InMemoryResource parent, InputStream stream, String fileName) {
  this.parent = parent;
  try {
    self = new ByteArray();
    if (stream != null) {
      self.bytes = IO.readBytes(stream);
    }
  } catch (IOException e) {
    throw new RuntimeException(String.format("Unable to read input stream for %s", fileName) );
  }
  this.fileName = fileName;
}

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

@Override
public void copyTo(File destination) throws IOException
{
  if (isDirectory())
  {
    IO.copyDir(this.path.toFile(),destination);
  }
  else
  {
    Files.copy(this.path,destination.toPath());
  }
}

相关文章