commons-io-1.3.2

oFile(url);
      }
    }
    return files;
  }
  
  public static URL[] toURLs(File[] files)
    throws IOException
  {
    URL[] urls = new URL[files.length];
    for (int i = 0; i < urls.length; i++) {
      urls[i] = files[i].toURL();
    }
    return urls;
  }
  
  public static void copyFileToDirectory(File srcFile, File destDir)
    throws IOException
  {
    copyFileToDirectory(srcFile, destDir, true);
  }
  
  public static void copyFileToDirectory(File srcFile, File destDir, boolean preserveFileDate)
    throws IOException
  {
    if (destDir == null) {
      throw new NullPointerException("Destination must not be null");
    }
    if ((destDir.exists()) && (!destDir.isDirectory())) {
      throw new IllegalArgumentException("Destination '" + destDir + "' is not a directory");
    }
    copyFile(srcFile, new File(destDir, srcFile.getName()), preserveFileDate);
  }
  
  public static void copyFile(File srcFile, File destFile)
    throws IOException
  {
    copyFile(srcFile, destFile, true);
  }
  
  public static void copyFile(File srcFile, File destFile, boolean preserveFileDate)
    throws IOException
  {
    if (srcFile == null) {
      throw new NullPointerException("Source must not be null");
    }
    if (destFile == null) {
      throw new NullPointerException("Destination must not be null");
    }
    if (!srcFile.exists()) {
      throw new FileNotFoundException("Source '" + srcFile + "' does not exist");
    }
    if (srcFile.isDirectory()) {
      throw new IOException("Source '" + srcFile + "' exists but is a directory");
    }
    if (srcFile.getCanonicalPath().equals(destFile.getCanonicalPath())) {
      throw new IOException("Source '" + srcFile + "' and destination '" + destFile + "' are the same");
    }
    if ((destFile.getParentFile() != null) && (!destFile.getParentFile().exists()) && 
      (!destFile.getParentFile().mkdirs())) {
      throw new IOException("Destination '" + destFile + "' directory cannot be created");
    }
    if ((destFile.exists()) && (!destFile.canWrite())) {
      throw new IOException("Destination '" + destFile + "' exists but is read-only");
    }
    doCopyFile(srcFile, destFile, preserveFileDate);
  }
  
  private static void doCopyFile(File srcFile, File destFile, boolean preserveFileDate)
    throws IOException
  {
    if ((destFile.exists()) && (destFile.isDirectory())) {
      throw new IOException("Destination '" + destFile + "' exists but is a directory");
    }
    FileInputStream input = new FileInputStream(srcFile);
    try
    {
      FileOutputStream output = new FileOutputStream(destFile);
      try
      {
        IOUtils.copy(input, output);
      }
      finally {}
    }
    finally
    {
      IOUtils.closeQuietly(input);
    }
    if (srcFile.length() != destFile.length()) {
      throw new IOException("Failed to copy full contents from '" + srcFile + "' to '" + destFile + "'");
    }
    if (preserveFileDate) {
      destFile.setLastModified(srcFile.lastModified());
    }
  }
  
  public static void copyDirectoryToDirectory(File srcDir, File destDir)
    throws IOException
  {
    if (srcDir == null) {
      throw new NullPointerException("Source must not be null");
    }
    if ((srcDir.exists()) && (!srcDir.isDirectory())) {
      throw new IllegalArgumentException("Source '" + destDir + "' is not a directory");
    }
    if (destDir == null) {
      throw new NullPointerException("Destination must not be null");
    }
    if ((destDir.exists()) && (!destDir.isDirectory())) {
      throw new IllegalArgumentException("Destination '" + destDir + "' is not a directory");
    }
    copyDirectory(srcDir, new File(destDir, srcDir.getName()), true);
  }
  
  public static void copyDirectory(File srcDir, File destDir)
    throws IOException
  {
    copyDirectory(srcDir, destDir, true);
  }
  
  public static void copyDirectory(File srcDir, File destDir, boolean preserveFileDate)
    throws IOException
  {
    if (srcDir == null) {
      throw new NullPointerException("Source must not be null");
    }
    if (destDir == null) {
      throw new NullPointerException("Destination must not be null");
    }
    if (!srcDir.exists()) {
      throw new FileNotFoundException("Source '" + srcDir + "' does not exist");
    }
    if (!srcDir.isDirectory()) {
      throw new IOException("Source '" + srcDir + "' exists but is not a directory");
    }
    if (srcDir.getCanonicalPath().equals(destDir.getCanonicalPath())) {
      throw new IOException("Source '" + srcDir + "' and destination '" + destDir + "' are the same");
    }
    doCopyDirectory(srcDir, destDir, preserveFileDate);
  }
  
  private static void doCopyDirectory(File srcDir, File destDir, boolean preserveFileDate)
    throws IOException
  {
    if (destDir.exists())
    {
      if (!destDir.isDirectory()) {
        throw new IOException("Destination '" + destDir + "' exists but is not a directory");
      }
    }
    else
    {
      if (!destDir.mkdirs()) {
        throw new IOException("Destination '" + destDir + "' directory cannot be created");
      }
      if (preserveFileDate) {
        destDir.setLastModified(srcDir.lastModified());
      }
    }
    if (!destDir.canWrite()) {
      throw new IOException("Destination '" + destDir + "' cannot be written to");
    }
    File[] files = srcDir.listFiles();
    if (files == null) {
      throw new IOException("Failed to list contents of " + srcDir);
    }
    for (int i = 0; i < files.length; i++)
    {
      File copiedFile = new File(destDir, files[i].getName());
      if (files[i].isDirectory()) {
        doCopyDirectory(files[i], copiedFile, preserveFileDate);
      } else {
        doCopyFile(files[i], copiedFile, preserveFileDate);
      }
    }
  }
  
  public static void copyURLToFile(URL source, File destination)
    throws IOException
  {
    InputStream input = source.openStream();
    try
    {
      FileOutputStream output = openOutputStream(destination);
      try
      {
        IOUtils.copy(input, output);
      }
      finally {}
    }
    finally
    {
      IOUtils.closeQuietly(input);
    }
  }
  
  public static void deleteDirectory(File directory)
    throws IOException
  {
    if (!directory.exists()) {
      return;
    }
    cleanDirectory(directory);
    if (!directory.delete())
    {
      String message = "Unable to delete directory " + directory + ".";
      
      throw new IOException(message);
    }
  }
  
  public static void cleanDirectory(File directory)
    throws IOException
  {
    if (!directory.exists())
    {
      String message = directory + " does not exist";
      throw new IllegalArgumentException(message);
    }
    if (!directory.isDirectory())
    {
      String message = directory + " is not a directory";
      throw new IllegalArgumentException(message);
    }
    File[] files = directory.listFiles();
    if (files == null) {
      throw new IOException("Failed to list contents of " + directory);
    }
    IOException exception = null;
    for (int i = 0; i < files.length; i++)
    {
      File file = files[i];
      try
      {
        forceDelete(file);
      }
      catch (IOException ioe)
      {
        exception = ioe;
      }
    }
    if (null != exception) {
      throw exception;
    }
  }
  
  public static boolean waitFor(File file, int seconds)
  {
    int timeout = 0;
    int tick = 0;
    for (;;)
    {
      if (!file.exists())
      {
        if (tick++ >= 10)
        {
          tick = 0;
          if (timeout++ > seconds) {
            return false;
          }
        }
        try
        {
          Thread.sleep(100L);
        }
        catch (InterruptedException ignore) {}catch (Exception ex) {}
      }
    }
    return true;
  }
  
  public static String readFileToString(File file, String encoding)
    throws IOException
  {
    InputStream in = null;
    try
    {
      in = openInputStream(file);
      return IOUtils.toString(in, encoding);
    }
    finally
    {
      IOUtils.closeQuietly(in);
    }
  }
  
  public static String readFileToString(File file)
    throws IOException
  {
    return readFileToString(file, null);
  }
  
  public static byte[] readFileToByteArray(File file)
    throws IOException
  {
    InputStream in = null;
    try
    {
      in = openInputStream(file);
      return IOUtils.toByteArray(in);
    }
    finally
    {
      IOUtils.closeQuietly(in);
    }
  }
  
  public static List readLines(File file, String encoding)
    throws IOException
  {
    InputStream in = null;
    try
    {
      in = openInputStream(file);
      return IOUtils.readLines(in, encoding);
    }
    finally
    {
      IOUtils.closeQuietly(in);
    }
  }
  
  public static List readLines(File file)
    throws IOException
  {
    return readLines(file, null);
  }
  
  public static LineIterator lineIterator(File file, String encoding)
    throws IOException
  {
    InputStream in = null;
    try
    {
      in = openInputStream(file);
      return IOUtils.lineIterator(in, encoding);
    }
    catch (IOException ex)
    {
      IOUtils.closeQuietly(in);
      throw ex;
    }
    catch (RuntimeException ex)
    {
      IOUtils.closeQuietly(in);
      throw ex;
    }
  }
  
  public static LineIterator lineIterator(File file)
    throws IOException
  {
    return lineIterator(file, null);
  }
  
  public static void writeStringToFile(File file, String data, String encoding)
    throws IOException
  {
    OutputStream out = null;
    try
    {
      out = openOutputStream(file);
      IOUtils.write(data, out, encoding);
    }
    finally
    {
      IOUtils.closeQuietly(out);
    }
  }
  
  public static void writeStringToFile(File file, String data)
    throws IOException
  {
    writeStringToFile(file, data, null);
  }
  
  public static void writeByteArrayToFile(File file, byte[] data)
    throws IOException
  {
    OutputStream out = null;
    try
    {
      out = openOutputStream(file);
      out.write(data);
    }
    finally
    {
      IOUtils.closeQuietly(out);
    }
  }
  
  public static void writeLines(File file, String encoding, Collection lines)
    throws IOException
  {
    writeLines(file, encoding, lines, null);
  }
  
  public static void writeLines(File file, Collection lines)
    throws IOException
  {
    writeLines(file, null, lines, null);
  }
  
  public static void writeLines(File file, String encoding, Collection lines, String lineEnding)
    throws IOException
  {
    OutputStream out = null;
    try
    {
      out = openOutputStream(file);
      IOUtils.writeLines(lines, lineEnding, out, encoding);
    }
    finally
    {
      IOUtils.closeQuietly(out);
    }
  }
  
  public static void writeLines(File file, Collection lines, String lineEnding)
    throws IOException
  {
    writeLines(file, null, lines, lineEnding);
  }
  
  public static void forceDelete(File file)
    throws IOException
  {
    if (file.isDirectory())
    {
      deleteDirectory(file);
    }
    else
    {
      if (!file.exists()) {
        throw new FileNotFoundException("File does not exist: " + file);
      }
      if (!file.delete())
      {
        String message = "Unable to delete file: " + file;
        
        throw new IOException(message);
      }
    }
  }
  
  public static void forceDeleteOnExit(File file)
    throws IOException
  {
    if (file.isDirectory()) {
      deleteDirectoryOnExit(file);
    } else {
      file.deleteOnExit();
    }
  }
  
  private static void deleteDirectoryOnExit(File directory)
    throws IOException
  {
    if (!directory.exists()) {
      return;
    }
    cleanDirectoryOnExit(directory);
    directory.deleteOnExit();
  }
  
  private static void cleanDirectoryOnExit(File directory)
    throws IOException
  {
    if (!directory.exists())
    {
      String message = directory + " does not exist";
      throw new IllegalArgumentException(message);
    }
    if (!directory.isDirectory())
    {
      String message = directory + " is not a directory";
      throw new IllegalArgumentException(message);
    }
    File[] files = directory.listFiles();
    if (files == null) {
      throw new IOException("Failed to list contents of " + directory);
    }
    IOException exception = null;
    for (int i = 0; i < files.length; i++)
    {
      File file = files[i];
      try
      {
        forceDeleteOnExit(file);
      }
      catch (IOException ioe)
      {
        exception = ioe;
      }
    }
    if (null != exception) {
      throw exception;
    }
  }
  
  public static void forceMkdir(File directory)
    throws IOException
  {
    if (directory.exists())
    {
      if (directory.isFile())
      {
        String message = "File " + directory + " exists and is " + "not a directory. Unable to create directory.";
        
        throw new IOException(message);
      }
    }
    else if (!directory.mkdirs())
    {
      String message = "Unable to create directory " + directory;
      
      throw new IOException(message);
    }
  }
  
  public static long sizeOfDirectory(File directory)
  {
    if (!directory.exists())
    {
      String message = directory + " does not exist";
      throw new IllegalArgumentException(message);
    }
    if (!directory.isDirectory())
    {
      String message = directory + " is not a directory";
      throw new IllegalArgumentException(message);
    }
    long size = 0L;
    
    File[] files = directory.listFiles();
    if (files == null) {
      return 0L;
    }
    for (int i = 0; i < files.length; i++)
    {
      File file = files[i];
      if (file.isDirectory()) {
        size += sizeOfDirectory(file);
      } else {
        size += file.length();
      }
    }
    return size;
  }
  
  public static boolean isFileNewer(File file, File reference)
  {
    if (reference == null) {
      throw new IllegalArgumentException("No specified reference file");
    }
    if (!reference.exists()) {
      throw new IllegalArgumentException("The reference file '" + file + "' doesn't exist");
    }
    return isFileNewer(file, reference.lastModified());
  }
  
  public static boolean isFileNewer(File file, Date date)
  {
    if (date == null) {
      throw new IllegalArgumentException("No specified date");
    }
    return isFileNewer(file, date.getTime());
  }
  
  public static boolean isFileNewer(File file, long timeMillis)
  {
    if (file == null) {
      throw new IllegalArgumentException("No specified file");
    }
    if (!file.exists()) {
      return false;
    }
    return file.lastModified() > timeMillis;
  }
  
  public static boolean isFileOlder(File file, File reference)
  {
    if (reference == null) {
      throw new IllegalArgumentException("No specified reference file");
    }
    if (!reference.exists()) {
      throw new IllegalArgumentException("The reference file '" + file + "' doesn't exist");
    }
    return isFileOlder(file, reference.lastModified());
  }
  
  public static boolean isFileOlder(File file, Date date)
  {
    if (date == null) {
      throw new IllegalArgumentException("No specified date");
    }
    return isFileOlder(file, date.getTime());
  }
  
  public static boolean isFileOlder(File file, long timeMillis)
  {
    if (file == null) {
      throw new IllegalArgumentException("No specified file");
    }
    if (!file.exists()) {
      return false;
    }
    return file.lastModified() < timeMillis;
  }
  
  public static long checksumCRC32(File file)
    throws IOException
  {
    CRC32 crc = new CRC32();
    checksum(file, crc);
    return crc.getValue();
  }
  
  public static Checksum checksum(File file, Checksum checksum)
    throws IOException
  {
    if (file.isDirectory()) {
      throw new IllegalArgumentException("Checksums can't be computed on directories");
    }
    InputStream in = null;
    try
    {
      in = new CheckedInputStream(new FileInputStream(file), checksum);
      IOUtils.copy(in, new NullOutputStream());
    }
    finally
    {
      IOUtils.closeQuietly(in);
    }
    return checksum;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.FileUtils
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io;

import java.io.IOException;
import java.io.OutputStream;

public class HexDump
{
  public static void dump(byte[] data, long offset, OutputStream stream, int index)
    throws IOException, ArrayIndexOutOfBoundsException, IllegalArgumentException
  {
    if ((index < 0) || (index >= data.length)) {
      throw new ArrayIndexOutOfBoundsException("illegal index: " + index + " into array of length " + data.length);
    }
    if (stream == null) {
      throw new IllegalArgumentException("cannot write to nullstream");
    }
    long display_offset = offset + index;
    StringBuffer buffer = new StringBuffer(74);
    for (int j = index; j < data.length; j += 16)
    {
      int chars_read = data.length - j;
      if (chars_read > 16) {
        chars_read = 16;
      }
      buffer.append(dump(display_offset)).append(' ');
      for (int k = 0; k < 16; k++)
      {
        if (k < chars_read) {
          buffer.append(dump(data[(k + j)]));
        } else {
          buffer.append("  ");
        }
        buffer.append(' ');
      }
      for (int k = 0; k < chars_read; k++) {
        if ((data[(k + j)] >= 32) && (data[(k + j)] < Byte.MAX_VALUE)) {
          buffer.append((char)data[(k + j)]);
        } else {
          buffer.append('.');
        }
      }
      buffer.append(EOL);
      stream.write(buffer.toString().getBytes());
      stream.flush();
      buffer.setLength(0);
      display_offset += chars_read;
    }
  }
  
  public static final String EOL = System.getProperty("line.separator");
  private static final StringBuffer _lbuffer = new StringBuffer(8);
  private static final StringBuffer _cbuffer = new StringBuffer(2);
  private static final char[] _hexcodes = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
  private static final int[] _shifts = { 28, 24, 20, 16, 12, 8, 4, 0 };
  
  private static StringBuffer dump(long value)
  {
    _lbuffer.setLength(0);
    for (int j = 0; j < 8; j++) {
      _lbuffer.append(_hexcodes[((int)(value >> _shifts[j]) & 0xF)]);
    }
    return _lbuffer;
  }
  
  private static StringBuffer dump(byte value)
  {
    _cbuffer.setLength(0);
    for (int j = 0; j < 2; j++) {
      _cbuffer.append(_hexcodes[(value >> _shifts[(j + 6)] & 0xF)]);
    }
    return _cbuffer;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.HexDump
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.input;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
import java.io.StreamCorruptedException;

public class ClassLoaderObjectInputStream
  extends ObjectInputStream
{
  private ClassLoader classLoader;
  
  public ClassLoaderObjectInputStream(ClassLoader classLoader, InputStream inputStream)
    throws IOException, StreamCorruptedException
  {
    super(inputStream);
    this.classLoader = classLoader;
  }
  
  protected Class resolveClass(ObjectStreamClass objectStreamClass)
    throws IOException, ClassNotFoundException
  {
    Class clazz = Class.forName(objectStreamClass.getName(), false, classLoader);
    if (clazz != null) {
      return clazz;
    }
    return super.resolveClass(objectStreamClass);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.input.ClassLoaderObjectInputStream
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.input;

import java.io.IOException;
import java.io.InputStream;

public class CountingInputStream
  extends ProxyInputStream
{
  private long count;
  
  public CountingInputStream(InputStream in)
  {
    super(in);
  }
  
  public int read(byte[] b)
    throws IOException
  {
    int found = super.read(b);
    count += (found >= 0 ? found : 0L);
    return found;
  }
  
  public int read(byte[] b, int off, int len)
    throws IOException
  {
    int found = super.read(b, off, len);
    count += (found >= 0 ? found : 0L);
    return found;
  }
  
  public int read()
    throws IOException
  {
    int found = super.read();
    count += (found >= 0 ? 1L : 0L);
    return found;
  }
  
  public long skip(long length)
    throws IOException
  {
    long skip = super.skip(length);
    count += skip;
    return skip;
  }
  
  public synchronized int getCount()
  {
    long result = getByteCount();
    if (result > 2147483647L) {
      throw new ArithmeticException("The byte count " + result + " is too large to be converted to an int");
    }
    return (int)result;
  }
  
  public synchronized int resetCount()
  {
    long result = resetByteCount();
    if (result > 2147483647L) {
      throw new ArithmeticException("The byte count " + result + " is too large to be converted to an int");
    }
    return (int)result;
  }
  
  public synchronized long getByteCount()
  {
    return count;
  }
  
  public synchronized long resetByteCount()
  {
    long tmp = count;
    count = 0L;
    return tmp;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.input.CountingInputStream
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.input;

import java.io.IOException;
import java.io.InputStream;

public class DemuxInputStream
  extends InputStream
{
  private InheritableThreadLocal m_streams = new InheritableThreadLocal();
  
  public InputStream bindStream(InputStream input)
  {
    InputStream oldValue = getStream();
    m_streams.set(input);
    return oldValue;
  }
  
  public void close()
    throws IOException
  {
    InputStream input = getStream();
    if (null != input) {
      input.close();
    }
  }
  
  public int read()
    throws IOException
  {
    InputStream input = getStream();
    if (null != input) {
      return input.read();
    }
    return -1;
  }
  
  private InputStream getStream()
  {
    return (InputStream)m_streams.get();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.input.DemuxInputStream
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.input;

import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;

public class NullInputStream
  extends InputStream
{
  private long size;
  private long position;
  private long mark = -1L;
  private long readlimit;
  private boolean eof;
  private boolean throwEofException;
  private boolean markSupported;
  
  public NullInputStream(long size)
  {
    this(size, true, false);
  }
  
  public NullInputStream(long size, boolean markSupported, boolean throwEofException)
  {
    this.size = size;
    this.markSupported = markSupported;
    this.throwEofException = throwEofException;
  }
  
  public long getPosition()
  {
    return position;
  }
  
  public long getSize()
  {
    return size;
  }
  
  public int available()
  {
    long avail = size - position;
    if (avail <= 0L) {
      return 0;
    }
    if (avail > 2147483647L) {
      return Integer.MAX_VALUE;
    }
    return (int)avail;
  }
  
  public void close()
    throws IOException
  {
    eof = false;
    position = 0L;
    mark = -1L;
  }
  
  public synchronized void mark(int readlimit)
  {
    if (!markSupported) {
      throw new UnsupportedOperationException("Mark not supported");
    }
    mark = position;
    this.readlimit = readlimit;
  }
  
  public boolean markSupported()
  {
    return markSupported;
  }
  
  public int read()
    throws IOException
  {
    if (eof) {
      throw new IOException("Read after end of file");
    }
    if (position == size) {
      return doEndOfFile();
    }
    position += 1L;
    return processByte();
  }
  
  public int read(byte[] bytes)
    throws IOException
  {
    return read(bytes, 0, bytes.length);
  }
  
  public int read(byte[] bytes, int offset, int length)
    throws IOException
  {
    if (eof) {
      throw new IOException("Read after end of file");
    }
    if (position == size) {
      return doEndOfFile();
    }
    position += length;
    int returnLength = length;
    if (position > size)
    {
      returnLength = length - (int)(position - size);
      position = size;
    }
    processBytes(bytes, offset, returnLength);
    return returnLength;
  }
  
  public synchronized void reset()
    throws IOException
  {
    if (!markSupported) {
      throw new UnsupportedOperationException("Mark not supported");
    }
    if (mark < 0L) {
      throw new IOException("No position has been marked");
    }
    if (position > mark + readlimit) {
      throw new IOException("Marked position [" + mark + "] is no longer valid - passed the read limit [" + readlimit + "]");
    }
    position = mark;
    eof = false;
  }
  
  public long skip(long numberOfBytes)
    throws IOException
  {
    if (eof) {
      throw new IOException("Skip after end of file");
    }
    if (position == size) {
      return doEndOfFile();
    }
    position += numberOfBytes;
    long returnLength = numberOfBytes;
    if (position > size)
    {
      returnLength = numberOfBytes - (position - size);
      position = size;
    }
    return returnLength;
  }
  
  protected int processByte()
  {
    return 0;
  }
  
  protected void processBytes(byte[] bytes, int offset, int length) {}
  
  private int doEndOfFile()
    throws EOFException
  {
    eof = true;
    if (throwEofException) {
      throw new EOFException();
    }
    return -1;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.input.NullInputStream
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.input;

import java.io.EOFException;
import java.io.IOException;
import java.io.Reader;

public class NullReader
  extends Reader
{
  private long size;
  private long position;
  private long mark = -1L;
  private long readlimit;
  private boolean eof;
  private boolean throwEofException;
  private boolean markSupported;
  
  public NullReader(long size)
  {
    this(size, true, false);
  }
  
  public NullReader(long size, boolean markSupported, boolean throwEofException)
  {
    this.size = size;
    this.markSupported = markSupported;
    this.throwEofException = throwEofException;
  }
  
  public long getPosition()
  {
    return position;
  }
  
  public long getSize()
  {
    return size;
  }
  
  public void close()
    throws IOException
  {
    eof = false;
    position = 0L;
    mark = -1L;
  }
  
  public synchronized void mark(int readlimit)
  {
    if (!markSupported) {
      throw new UnsupportedOperationException("Mark not supported");
    }
    mark = position;
    this.readlimit = readlimit;
  }
  
  public boolean markSupported()
  {
    return markSupported;
  }
  
  public int read()
    throws IOException
  {
    if (eof) {
      throw new IOException("Read after end of file");
    }
    if (position == size) {
      return doEndOfFile();
    }
    position += 1L;
    return processChar();
  }
  
  public int read(char[] chars)
    throws IOException
  {
    return read(chars, 0, chars.length);
  }
  
  public int read(char[] chars, int offset, int length)
    throws IOException
  {
    if (eof) {
      throw new IOException("Read after end of file");
    }
    if (position == size) {
      return doEndOfFile();
    }
    position += length;
    int returnLength = length;
    if (position > size)
    {
      returnLength = length - (int)(position - size);
      position = size;
    }
    processChars(chars, offset, returnLength);
    return returnLength;
  }
  
  public synchronized void reset()
    throws IOException
  {
    if (!markSupported) {
      throw new UnsupportedOperationException("Mark not supported");
    }
    if (mark < 0L) {
      throw new IOException("No position has been marked");
    }
    if (position > mark + readlimit) {
      throw new IOException("Marked position [" + mark + "] is no longer valid - passed the read limit [" + readlimit + "]");
    }
    position = mark;
    eof = false;
  }
  
  public long skip(long numberOfChars)
    throws IOException
  {
    if (eof) {
      throw new IOException("Skip after end of file");
    }
    if (position == size) {
      return doEndOfFile();
    }
    position += numberOfChars;
    long returnLength = numberOfChars;
    if (position > size)
    {
      returnLength = numberOfChars - (position - size);
      position = size;
    }
    return returnLength;
  }
  
  protected int processChar()
  {
    return 0;
  }
  
  protected void processChars(char[] chars, int offset, int length) {}
  
  private int doEndOfFile()
    throws EOFException
  {
    eof = true;
    if (throwEofException) {
      throw new EOFException();
    }
    return -1;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.input.NullReader
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.input;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

public abstract class ProxyInputStream
  extends FilterInputStream
{
  public ProxyInputStream(InputStream proxy)
  {
    super(proxy);
  }
  
  public int read()
    throws IOException
  {
    return in.read();
  }
  
  public int read(byte[] bts)
    throws IOException
  {
    return in.read(bts);
  }
  
  public int read(byte[] bts, int st, int end)
    throws IOException
  {
    return in.read(bts, st, end);
  }
  
  public long skip(long ln)
    throws IOException
  {
    return in.skip(ln);
  }
  
  public int available()
    throws IOException
  {
    return in.available();
  }
  
  public void close()
    throws IOException
  {
    in.close();
  }
  
  public synchronized void mark(int idx)
  {
    in.mark(idx);
  }
  
  public synchronized void reset()
    throws IOException
  {
    in.reset();
  }
  
  public boolean markSupported()
  {
    return in.markSupported();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.input.ProxyInputStream
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.input;

import java.io.FilterReader;
import java.io.IOException;
import java.io.Reader;

public abstract class ProxyReader
  extends FilterReader
{
  public ProxyReader(Reader proxy)
  {
    super(proxy);
  }
  
  public int read()
    throws IOException
  {
    return in.read();
  }
  
  public int read(char[] chr)
    throws IOException
  {
    return in.read(chr);
  }
  
  public int read(char[] chr, int st, int end)
    throws IOException
  {
    return in.read(chr, st, end);
  }
  
  public long skip(long ln)
    throws IOException
  {
    return in.skip(ln);
  }
  
  public boolean ready()
    throws IOException
  {
    return in.ready();
  }
  
  public void close()
    throws IOException
  {
    in.close();
  }
  
  public synchronized void mark(int idx)
    throws IOException
  {
    in.mark(idx);
  }
  
  public synchronized void reset()
    throws IOException
  {
    in.reset();
  }
  
  public boolean markSupported()
  {
    return in.markSupported();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.input.ProxyReader
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.input;

import java.io.DataInput;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.EndianUtils;

public class SwappedDataInputStream
  extends ProxyInputStream
  implements DataInput
{
  public SwappedDataInputStream(InputStream input)
  {
    super(input);
  }
  
  public boolean readBoolean()
    throws IOException, EOFException
  {
    return 0 == readByte();
  }
  
  public byte readByte()
    throws IOException, EOFException
  {
    return (byte)in.read();
  }
  
  public char readChar()
    throws IOException, EOFException
  {
    return (char)readShort();
  }
  
  public double readDouble()
    throws IOException, EOFException
  {
    return EndianUtils.readSwappedDouble(in);
  }
  
  public float readFloat()
    throws IOException, EOFException
  {
    return EndianUtils.readSwappedFloat(in);
  }
  
  public void readFully(byte[] data)
    throws IOException, EOFException
  {
    readFully(data, 0, data.length);
  }
  
  public void readFully(byte[] data, int offset, int length)
    throws IOException, EOFException
  {
    int remaining = length;
    while (remaining > 0)
    {
      int location = offset + (length - remaining);
      int count = read(data, location, remaining);
      if (-1 == count) {
        throw new EOFException();
      }
      remaining -= count;
    }
  }
  
  public int readInt()
    throws IOException, EOFException
  {
    return EndianUtils.readSwappedInteger(in);
  }
  
  public String readLine()
    throws IOException, EOFException
  {
    throw new UnsupportedOperationException("Operation not supported: readLine()");
  }
  
  public long readLong()
    throws IOException, EOFException
  {
    return EndianUtils.readSwappedLong(in);
  }
  
  public short readShort()
    throws IOException, EOFException
  {
    return EndianUtils.readSwappedShort(in);
  }
  
  public int readUnsignedByte()
    throws IOException, EOFException
  {
    return in.read();
  }
  
  public int readUnsignedShort()
    throws IOException, EOFException
  {
    return EndianUtils.readSwappedUnsignedShort(in);
  }
  
  public String readUTF()
    throws IOException, EOFException
  {
    throw new UnsupportedOperationException("Operation not supported: readUTF()");
  }
  
  public int skipBytes(int count)
    throws IOException, EOFException
  {
    return (int)in.skip(count);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.input.SwappedDataInputStream
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io;

import java.io.Serializable;

public final class IOCase
  implements Serializable
{
  public static final IOCase SENSITIVE = new IOCase("Sensitive", true);
  public static final IOCase INSENSITIVE = new IOCase("Insensitive", false);
  public static final IOCase SYSTEM = new IOCase("System", !FilenameUtils.isSystemWindows());
  private static final long serialVersionUID = -6343169151696340687L;
  private final String name;
  private final transient boolean sensitive;
  
  public static IOCase forName(String name)
  {
    if (SENSITIVEname.equals(name)) {
      return SENSITIVE;
    }
    if (INSENSITIVEname.equals(name)) {
      return INSENSITIVE;
    }
    if (SYSTEMname.equals(name)) {
      return SYSTEM;
    }
    throw new IllegalArgumentException("Invalid IOCase name: " + name);
  }
  
  private IOCase(String name, boolean sensitive)
  {
    this.name = name;
    this.sensitive = sensitive;
  }
  
  private Object readResolve()
  {
    return forName(name);
  }
  
  public String getName()
  {
    return name;
  }
  
  public boolean isCaseSensitive()
  {
    return sensitive;
  }
  
  public boolean checkEquals(String str1, String str2)
  {
    if ((str1 == null) || (str2 == null)) {
      throw new NullPointerException("The strings must not be null");
    }
    return sensitive ? str1.equals(str2) : str1.equalsIgnoreCase(str2);
  }
  
  public boolean checkStartsWith(String str, String start)
  {
    return str.regionMatches(!sensitive, 0, start, 0, start.length());
  }
  
  public boolean checkEndsWith(String str, String end)
  {
    int endLen = end.length();
    return str.regionMatches(!sensitive, str.length() - endLen, end, 0, endLen);
  }
  
  public boolean checkRegionMatches(String str, int strStartIndex, String search)
  {
    return str.regionMatches(!sensitive, strStartIndex, search, 0, search.length());
  }
  
  String convertCase(String str)
  {
    if (str == null) {
      return null;
    }
    return sensitive ? str : str.toLowerCase();
  }
  
  public String toString()
  {
    return name;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.IOCase
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.CharArrayWriter;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.io.output.ByteArrayOutputStream;

public class IOUtils
{
  public static final char DIR_SEPARATOR_UNIX = '/';
  public static final char DIR_SEPARATOR_WINDOWS = '\\';
  public static final char DIR_SEPARATOR = File.separatorChar;
  public static final String LINE_SEPARATOR_UNIX = "\n";
  public static final String LINE_SEPARATOR_WINDOWS = "\r\n";
  public static final String LINE_SEPARATOR;
  private static final int DEFAULT_BUFFER_SIZE = 4096;
  
  static
  {
    StringWriter buf = new StringWriter(4);
    PrintWriter out = new PrintWriter(buf);
    out.println();
    LINE_SEPARATOR = buf.toString();
  }
  
  public static void closeQuietly(Reader input)
  {
    try
    {
      if (input != null) {
        input.close();
      }
    }
    catch (IOException ioe) {}
  }
  
  public static void closeQuietly(Writer output)
  {
    try
    {
      if (output != null) {
        output.close();
      }
    }
    catch (IOException ioe) {}
  }
  
  public static void closeQuietly(InputStream input)
  {
    try
    {
      if (input != null) {
        input.close();
      }
    }
    catch (IOException ioe) {}
  }
  
  public static void closeQuietly(OutputStream output)
  {
    try
    {
      if (output != null) {
        output.close();
      }
    }
    catch (IOException ioe) {}
  }
  
  public static byte[] toByteArray(InputStream input)
    throws IOException
  {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    copy(input, output);
    return output.toByteArray();
  }
  
  public static byte[] toByteArray(Reader input)
    throws IOException
  {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    copy(input, output);
    return output.toByteArray();
  }
  
  public static byte[] toByteArray(Reader input, String encoding)
    throws IOException
  {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    copy(input, output, encoding);
    return output.toByteArray();
  }
  
  /**
   * @deprecated
   */
  public static byte[] toByteArray(String input)
    throws IOException
  {
    return input.getBytes();
  }
  
  public static char[] toCharArray(InputStream is)
    throws IOException
  {
    CharArrayWriter output = new CharArrayWriter();
    copy(is, output);
    return output.toCharArray();
  }
  
  public static char[] toCharArray(InputStream is, String encoding)
    throws IOException
  {
    CharArrayWriter output = new CharArrayWriter();
    copy(is, output, encoding);
    return output.toCharArray();
  }
  
  public static char[] toCharArray(Reader input)
    throws IOException
  {
    CharArrayWriter sw = new CharArrayWriter();
    copy(input, sw);
    return sw.toCharArray();
  }
  
  public static String toString(InputStream input)
    throws IOException
  {
    StringWriter sw = new StringWriter();
    copy(input, sw);
    return sw.toString();
  }
  
  public static String toString(InputStream input, String encoding)
    throws IOException
  {
    StringWriter sw = new StringWriter();
    copy(input, sw, encoding);
    return sw.toString();
  }
  
  public static String toString(Reader input)
    throws IOException
  {
    StringWriter sw = new StringWriter();
    copy(input, sw);
    return sw.toString();
  }
  
  /**
   * @deprecated
   */
  public static String toString(byte[] input)
    throws IOEx
1 2 3 4

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd