commons-io-1.3.2

ception
  {
    return new String(input);
  }
  
  /**
   * @deprecated
   */
  public static String toString(byte[] input, String encoding)
    throws IOException
  {
    if (encoding == null) {
      return new String(input);
    }
    return new String(input, encoding);
  }
  
  public static List readLines(InputStream input)
    throws IOException
  {
    InputStreamReader reader = new InputStreamReader(input);
    return readLines(reader);
  }
  
  public static List readLines(InputStream input, String encoding)
    throws IOException
  {
    if (encoding == null) {
      return readLines(input);
    }
    InputStreamReader reader = new InputStreamReader(input, encoding);
    return readLines(reader);
  }
  
  public static List readLines(Reader input)
    throws IOException
  {
    BufferedReader reader = new BufferedReader(input);
    List list = new ArrayList();
    String line = reader.readLine();
    while (line != null)
    {
      list.add(line);
      line = reader.readLine();
    }
    return list;
  }
  
  public static LineIterator lineIterator(Reader reader)
  {
    return new LineIterator(reader);
  }
  
  public static LineIterator lineIterator(InputStream input, String encoding)
    throws IOException
  {
    Reader reader = null;
    if (encoding == null) {
      reader = new InputStreamReader(input);
    } else {
      reader = new InputStreamReader(input, encoding);
    }
    return new LineIterator(reader);
  }
  
  public static InputStream toInputStream(String input)
  {
    byte[] bytes = input.getBytes();
    return new ByteArrayInputStream(bytes);
  }
  
  public static InputStream toInputStream(String input, String encoding)
    throws IOException
  {
    byte[] bytes = encoding != null ? input.getBytes(encoding) : input.getBytes();
    return new ByteArrayInputStream(bytes);
  }
  
  public static void write(byte[] data, OutputStream output)
    throws IOException
  {
    if (data != null) {
      output.write(data);
    }
  }
  
  public static void write(byte[] data, Writer output)
    throws IOException
  {
    if (data != null) {
      output.write(new String(data));
    }
  }
  
  public static void write(byte[] data, Writer output, String encoding)
    throws IOException
  {
    if (data != null) {
      if (encoding == null) {
        write(data, output);
      } else {
        output.write(new String(data, encoding));
      }
    }
  }
  
  public static void write(char[] data, Writer output)
    throws IOException
  {
    if (data != null) {
      output.write(data);
    }
  }
  
  public static void write(char[] data, OutputStream output)
    throws IOException
  {
    if (data != null) {
      output.write(new String(data).getBytes());
    }
  }
  
  public static void write(char[] data, OutputStream output, String encoding)
    throws IOException
  {
    if (data != null) {
      if (encoding == null) {
        write(data, output);
      } else {
        output.write(new String(data).getBytes(encoding));
      }
    }
  }
  
  public static void write(String data, Writer output)
    throws IOException
  {
    if (data != null) {
      output.write(data);
    }
  }
  
  public static void write(String data, OutputStream output)
    throws IOException
  {
    if (data != null) {
      output.write(data.getBytes());
    }
  }
  
  public static void write(String data, OutputStream output, String encoding)
    throws IOException
  {
    if (data != null) {
      if (encoding == null) {
        write(data, output);
      } else {
        output.write(data.getBytes(encoding));
      }
    }
  }
  
  public static void write(StringBuffer data, Writer output)
    throws IOException
  {
    if (data != null) {
      output.write(data.toString());
    }
  }
  
  public static void write(StringBuffer data, OutputStream output)
    throws IOException
  {
    if (data != null) {
      output.write(data.toString().getBytes());
    }
  }
  
  public static void write(StringBuffer data, OutputStream output, String encoding)
    throws IOException
  {
    if (data != null) {
      if (encoding == null) {
        write(data, output);
      } else {
        output.write(data.toString().getBytes(encoding));
      }
    }
  }
  
  public static void writeLines(Collection lines, String lineEnding, OutputStream output)
    throws IOException
  {
    if (lines == null) {
      return;
    }
    if (lineEnding == null) {
      lineEnding = LINE_SEPARATOR;
    }
    for (Iterator it = lines.iterator(); it.hasNext();)
    {
      Object line = it.next();
      if (line != null) {
        output.write(line.toString().getBytes());
      }
      output.write(lineEnding.getBytes());
    }
  }
  
  public static void writeLines(Collection lines, String lineEnding, OutputStream output, String encoding)
    throws IOException
  {
    Iterator it;
    if (encoding == null)
    {
      writeLines(lines, lineEnding, output);
    }
    else
    {
      if (lines == null) {
        return;
      }
      if (lineEnding == null) {
        lineEnding = LINE_SEPARATOR;
      }
      for (it = lines.iterator(); it.hasNext();)
      {
        Object line = it.next();
        if (line != null) {
          output.write(line.toString().getBytes(encoding));
        }
        output.write(lineEnding.getBytes(encoding));
      }
    }
  }
  
  public static void writeLines(Collection lines, String lineEnding, Writer writer)
    throws IOException
  {
    if (lines == null) {
      return;
    }
    if (lineEnding == null) {
      lineEnding = LINE_SEPARATOR;
    }
    for (Iterator it = lines.iterator(); it.hasNext();)
    {
      Object line = it.next();
      if (line != null) {
        writer.write(line.toString());
      }
      writer.write(lineEnding);
    }
  }
  
  public static int copy(InputStream input, OutputStream output)
    throws IOException
  {
    long count = copyLarge(input, output);
    if (count > 2147483647L) {
      return -1;
    }
    return (int)count;
  }
  
  public static long copyLarge(InputStream input, OutputStream output)
    throws IOException
  {
    byte[] buffer = new byte['?'];
    long count = 0L;
    int n = 0;
    while (-1 != (n = input.read(buffer)))
    {
      output.write(buffer, 0, n);
      count += n;
    }
    return count;
  }
  
  public static void copy(InputStream input, Writer output)
    throws IOException
  {
    InputStreamReader in = new InputStreamReader(input);
    copy(in, output);
  }
  
  public static void copy(InputStream input, Writer output, String encoding)
    throws IOException
  {
    if (encoding == null)
    {
      copy(input, output);
    }
    else
    {
      InputStreamReader in = new InputStreamReader(input, encoding);
      copy(in, output);
    }
  }
  
  public static int copy(Reader input, Writer output)
    throws IOException
  {
    long count = copyLarge(input, output);
    if (count > 2147483647L) {
      return -1;
    }
    return (int)count;
  }
  
  public static long copyLarge(Reader input, Writer output)
    throws IOException
  {
    char[] buffer = new char['?'];
    long count = 0L;
    int n = 0;
    while (-1 != (n = input.read(buffer)))
    {
      output.write(buffer, 0, n);
      count += n;
    }
    return count;
  }
  
  public static void copy(Reader input, OutputStream output)
    throws IOException
  {
    OutputStreamWriter out = new OutputStreamWriter(output);
    copy(input, out);
    
    out.flush();
  }
  
  public static void copy(Reader input, OutputStream output, String encoding)
    throws IOException
  {
    if (encoding == null)
    {
      copy(input, output);
    }
    else
    {
      OutputStreamWriter out = new OutputStreamWriter(output, encoding);
      copy(input, out);
      
      out.flush();
    }
  }
  
  public static boolean contentEquals(InputStream input1, InputStream input2)
    throws IOException
  {
    if (!(input1 instanceof BufferedInputStream)) {
      input1 = new BufferedInputStream(input1);
    }
    if (!(input2 instanceof BufferedInputStream)) {
      input2 = new BufferedInputStream(input2);
    }
    int ch = input1.read();
    while (-1 != ch)
    {
      int ch2 = input2.read();
      if (ch != ch2) {
        return false;
      }
      ch = input1.read();
    }
    int ch2 = input2.read();
    return ch2 == -1;
  }
  
  public static boolean contentEquals(Reader input1, Reader input2)
    throws IOException
  {
    if (!(input1 instanceof BufferedReader)) {
      input1 = new BufferedReader(input1);
    }
    if (!(input2 instanceof BufferedReader)) {
      input2 = new BufferedReader(input2);
    }
    int ch = input1.read();
    while (-1 != ch)
    {
      int ch2 = input2.read();
      if (ch != ch2) {
        return false;
      }
      ch = input1.read();
    }
    int ch2 = input2.read();
    return ch2 == -1;
  }
}

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

import java.io.BufferedReader;
import java.io.Reader;
import java.util.Iterator;
import java.util.NoSuchElementException;

public class LineIterator
  implements Iterator
{
  private final BufferedReader bufferedReader;
  private String cachedLine;
  private boolean finished = false;
  
  public LineIterator(Reader reader)
    throws IllegalArgumentException
  {
    if (reader == null) {
      throw new IllegalArgumentException("Reader must not be null");
    }
    if ((reader instanceof BufferedReader)) {
      bufferedReader = ((BufferedReader)reader);
    } else {
      bufferedReader = new BufferedReader(reader);
    }
  }
  
  /* Error */
  public boolean hasNext()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 9	org/apache/commons/io/LineIterator:cachedLine	Ljava/lang/String;
    //   4: ifnull +5 -> 9
    //   7: iconst_1
    //   8: ireturn
    //   9: aload_0
    //   10: getfield 2	org/apache/commons/io/LineIterator:finished	Z
    //   13: ifeq +5 -> 18
    //   16: iconst_0
    //   17: ireturn
    //   18: aload_0
    //   19: getfield 7	org/apache/commons/io/LineIterator:bufferedReader	Ljava/io/BufferedReader;
    //   22: invokevirtual 10	java/io/BufferedReader:readLine	()Ljava/lang/String;
    //   25: astore_1
    //   26: aload_1
    //   27: ifnonnull +10 -> 37
    //   30: aload_0
    //   31: iconst_1
    //   32: putfield 2	org/apache/commons/io/LineIterator:finished	Z
    //   35: iconst_0
    //   36: ireturn
    //   37: aload_0
    //   38: aload_1
    //   39: invokevirtual 11	org/apache/commons/io/LineIterator:isValidLine	(Ljava/lang/String;)Z
    //   42: ifeq +10 -> 52
    //   45: aload_0
    //   46: aload_1
    //   47: putfield 9	org/apache/commons/io/LineIterator:cachedLine	Ljava/lang/String;
    //   50: iconst_1
    //   51: ireturn
    //   52: goto -34 -> 18
    //   55: astore_1
    //   56: aload_0
    //   57: invokevirtual 13	org/apache/commons/io/LineIterator:close	()V
    //   60: new 14	java/lang/IllegalStateException
    //   63: dup
    //   64: aload_1
    //   65: invokevirtual 15	java/io/IOException:toString	()Ljava/lang/String;
    //   68: invokespecial 16	java/lang/IllegalStateException:<init>	(Ljava/lang/String;)V
    //   71: athrow
    // Line number table:
    //   Java source line #89	-> byte code offset #0
    //   Java source line #90	-> byte code offset #7
    //   Java source line #91	-> byte code offset #9
    //   Java source line #92	-> byte code offset #16
    //   Java source line #96	-> byte code offset #18
    //   Java source line #97	-> byte code offset #26
    //   Java source line #98	-> byte code offset #30
    //   Java source line #99	-> byte code offset #35
    //   Java source line #100	-> byte code offset #37
    //   Java source line #101	-> byte code offset #45
    //   Java source line #102	-> byte code offset #50
    //   Java source line #104	-> byte code offset #52
    //   Java source line #105	-> byte code offset #55
    //   Java source line #106	-> byte code offset #56
    //   Java source line #107	-> byte code offset #60
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	72	0	this	LineIterator
    //   25	22	1	line	String
    //   55	10	1	ioe	java.io.IOException
    // Exception table:
    //   from	to	target	type
    //   18	36	55	java/io/IOException
    //   37	51	55	java/io/IOException
    //   52	55	55	java/io/IOException
  }
  
  protected boolean isValidLine(String line)
  {
    return true;
  }
  
  public Object next()
  {
    return nextLine();
  }
  
  public String nextLine()
  {
    if (!hasNext()) {
      throw new NoSuchElementException("No more lines");
    }
    String currentLine = cachedLine;
    cachedLine = null;
    return currentLine;
  }
  
  public void close()
  {
    finished = true;
    IOUtils.closeQuietly(bufferedReader);
    cachedLine = null;
  }
  
  public void remove()
  {
    throw new UnsupportedOperationException("Remove unsupported on LineIterator");
  }
  
  public static void closeQuietly(LineIterator iterator)
  {
    if (iterator != null) {
      iterator.close();
    }
  }
}

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

import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

public class ByteArrayOutputStream
  extends OutputStream
{
  private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
  private List buffers = new ArrayList();
  private int currentBufferIndex;
  private int filledBufferSum;
  private byte[] currentBuffer;
  private int count;
  
  public ByteArrayOutputStream()
  {
    this(1024);
  }
  
  public ByteArrayOutputStream(int size)
  {
    if (size < 0) {
      throw new IllegalArgumentException("Negative initial size: " + size);
    }
    needNewBuffer(size);
  }
  
  private byte[] getBuffer(int index)
  {
    return (byte[])buffers.get(index);
  }
  
  private void needNewBuffer(int newcount)
  {
    if (currentBufferIndex < buffers.size() - 1)
    {
      filledBufferSum += currentBuffer.length;
      
      currentBufferIndex += 1;
      currentBuffer = getBuffer(currentBufferIndex);
    }
    else
    {
      int newBufferSize;
      if (currentBuffer == null)
      {
        int newBufferSize = newcount;
        filledBufferSum = 0;
      }
      else
      {
        newBufferSize = Math.max(currentBuffer.length << 1, newcount - filledBufferSum);
        
        filledBufferSum += currentBuffer.length;
      }
      currentBufferIndex += 1;
      currentBuffer = new byte[newBufferSize];
      buffers.add(currentBuffer);
    }
  }
  
  public void write(byte[] b, int off, int len)
  {
    if ((off < 0) || (off > b.length) || (len < 0) || (off + len > b.length) || (off + len < 0)) {
      throw new IndexOutOfBoundsException();
    }
    if (len == 0) {
      return;
    }
    synchronized (this)
    {
      int newcount = count + len;
      int remaining = len;
      int inBufferPos = count - filledBufferSum;
      while (remaining > 0)
      {
        int part = Math.min(remaining, currentBuffer.length - inBufferPos);
        System.arraycopy(b, off + len - remaining, currentBuffer, inBufferPos, part);
        remaining -= part;
        if (remaining > 0)
        {
          needNewBuffer(newcount);
          inBufferPos = 0;
        }
      }
      count = newcount;
    }
  }
  
  public synchronized void write(int b)
  {
    int inBufferPos = count - filledBufferSum;
    if (inBufferPos == currentBuffer.length)
    {
      needNewBuffer(count + 1);
      inBufferPos = 0;
    }
    currentBuffer[inBufferPos] = ((byte)b);
    count += 1;
  }
  
  public synchronized int size()
  {
    return count;
  }
  
  public void close()
    throws IOException
  {}
  
  public synchronized void reset()
  {
    count = 0;
    filledBufferSum = 0;
    currentBufferIndex = 0;
    currentBuffer = getBuffer(currentBufferIndex);
  }
  
  public synchronized void writeTo(OutputStream out)
    throws IOException
  {
    int remaining = count;
    for (int i = 0; i < buffers.size(); i++)
    {
      byte[] buf = getBuffer(i);
      int c = Math.min(buf.length, remaining);
      out.write(buf, 0, c);
      remaining -= c;
      if (remaining == 0) {
        break;
      }
    }
  }
  
  public synchronized byte[] toByteArray()
  {
    int remaining = count;
    if (remaining == 0) {
      return EMPTY_BYTE_ARRAY;
    }
    byte[] newbuf = new byte[remaining];
    int pos = 0;
    for (int i = 0; i < buffers.size(); i++)
    {
      byte[] buf = getBuffer(i);
      int c = Math.min(buf.length, remaining);
      System.arraycopy(buf, 0, newbuf, pos, c);
      pos += c;
      remaining -= c;
      if (remaining == 0) {
        break;
      }
    }
    return newbuf;
  }
  
  public String toString()
  {
    return new String(toByteArray());
  }
  
  public String toString(String enc)
    throws UnsupportedEncodingException
  {
    return new String(toByteArray(), enc);
  }
}

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

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

public class CountingOutputStream
  extends ProxyOutputStream
{
  private long count;
  
  public CountingOutputStream(OutputStream out)
  {
    super(out);
  }
  
  public void write(byte[] b)
    throws IOException
  {
    count += b.length;
    super.write(b);
  }
  
  public void write(byte[] b, int off, int len)
    throws IOException
  {
    count += len;
    super.write(b, off, len);
  }
  
  public void write(int b)
    throws IOException
  {
    count += 1L;
    super.write(b);
  }
  
  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.output.CountingOutputStream
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.output;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.commons.io.IOUtils;

public class DeferredFileOutputStream
  extends ThresholdingOutputStream
{
  private ByteArrayOutputStream memoryOutputStream;
  private OutputStream currentOutputStream;
  private File outputFile;
  private boolean closed = false;
  
  public DeferredFileOutputStream(int threshold, File outputFile)
  {
    super(threshold);
    this.outputFile = outputFile;
    
    memoryOutputStream = new ByteArrayOutputStream();
    currentOutputStream = memoryOutputStream;
  }
  
  protected OutputStream getStream()
    throws IOException
  {
    return currentOutputStream;
  }
  
  protected void thresholdReached()
    throws IOException
  {
    FileOutputStream fos = new FileOutputStream(outputFile);
    memoryOutputStream.writeTo(fos);
    currentOutputStream = fos;
    memoryOutputStream = null;
  }
  
  public boolean isInMemory()
  {
    return !isThresholdExceeded();
  }
  
  public byte[] getData()
  {
    if (memoryOutputStream != null) {
      return memoryOutputStream.toByteArray();
    }
    return null;
  }
  
  public File getFile()
  {
    return outputFile;
  }
  
  public void close()
    throws IOException
  {
    super.close();
    closed = true;
  }
  
  public void writeTo(OutputStream out)
    throws IOException
  {
    if (!closed) {
      throw new IOException("Stream not closed");
    }
    if (isInMemory())
    {
      memoryOutputStream.writeTo(out);
    }
    else
    {
      FileInputStream fis = new FileInputStream(outputFile);
      try
      {
        IOUtils.copy(fis, out);
      }
      finally
      {
        IOUtils.closeQuietly(fis);
      }
    }
  }
}

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

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

public class DemuxOutputStream
  extends OutputStream
{
  private InheritableThreadLocal m_streams = new InheritableThreadLocal();
  
  public OutputStream bindStream(OutputStream output)
  {
    OutputStream stream = getStream();
    m_streams.set(output);
    return stream;
  }
  
  public void close()
    throws IOException
  {
    OutputStream output = getStream();
    if (null != output) {
      output.close();
    }
  }
  
  public void flush()
    throws IOException
  {
    OutputStream output = getStream();
    if (null != output) {
      output.flush();
    }
  }
  
  public void write(int ch)
    throws IOException
  {
    OutputStream output = getStream();
    if (null != output) {
      output.write(ch);
    }
  }
  
  private OutputStream getStream()
  {
    return (OutputStream)m_streams.get();
  }
}

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

import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;

public class LockableFileWriter
  extends Writer
{
  private static final String LCK = ".lck";
  private final Writer out;
  private final File lockFile;
  
  public LockableFileWriter(String fileName)
    throws IOException
  {
    this(fileName, false, null);
  }
  
  public LockableFileWriter(String fileName, boolean append)
    throws IOException
  {
    this(fileName, append, null);
  }
  
  public LockableFileWriter(String fileName, boolean append, String lockDir)
    throws IOException
  {
    this(new File(fileName), append, lockDir);
  }
  
  public LockableFileWriter(File file)
    throws IOException
  {
    this(file, false, null);
  }
  
  public LockableFileWriter(File file, boolean append)
    throws IOException
  {
    this(file, append, null);
  }
  
  public LockableFileWriter(File file, boolean append, String lockDir)
    throws IOException
  {
    this(file, null, append, lockDir);
  }
  
  public LockableFileWriter(File file, String encoding)
    throws IOException
  {
    this(file, encoding, false, null);
  }
  
  public LockableFileWriter(File file, String encoding, boolean append, String lockDir)
    throws IOException
  {
    file = file.getAbsoluteFile();
    if (file.getParentFile() != null) {
      FileUtils.forceMkdir(file.getParentFile());
    }
    if (file.isDirectory()) {
      throw new IOException("File specified is a directory");
    }
    if (lockDir == null) {
      lockDir = System.getProperty("java.io.tmpdir");
    }
    File lockDirFile = new File(lockDir);
    FileUtils.forceMkdir(lockDirFile);
    testLockDir(lockDirFile);
    lockFile = new File(lockDirFile, file.getName() + ".lck");
    
    createLock();
    
    out = initWriter(file, encoding, append);
  }
  
  private void testLockDir(File lockDir)
    throws IOException
  {
    if (!lockDir.exists()) {
      throw new IOException("Could not find lockDir: " + lockDir.getAbsolutePath());
    }
    if (!lockDir.canWrite()) {
      throw new IOException("Could not write to lockDir: " + lockDir.getAbsolutePath());
    }
  }
  
  private void createLock()
    throws IOException
  {
    synchronized (LockableFileWriter.class)
    {
      if (!lockFile.createNewFile()) {
        throw new IOException("Can't write file, lock " + lockFile.getAbsolutePath() + " exists");
      }
      lockFile.deleteOnExit();
    }
  }
  
  private Writer initWriter(File file, String encoding, boolean append)
    throws IOException
  {
    boolean fileExistedAlready = file.exists();
    OutputStream stream = null;
    Writer writer = null;
    try
    {
      if (encoding == null)
      {
        writer = new FileWriter(file.getAbsolutePath(), append);
      }
      else
      {
        stream = new FileOutputStream(file.getAbsolutePath(), append);
        writer = new OutputStreamWriter(stream, encoding);
      }
    }
    catch (IOException ex)
    {
      IOUtils.closeQuietly(writer);
      IOUtils.closeQuietly(stream);
      lockFile.delete();
      if (!fileExistedAlready) {
        file.delete();
      }
      throw ex;
    }
    catch (RuntimeException ex)
    {
      IOUtils.closeQuietly(writer);
      IOUtils.closeQuietly(stream);
      lockFile.delete();
      if (!fileExistedAlready) {
        file.delete();
      }
      throw ex;
    }
    return writer;
  }
  
  public void close()
    throws IOException
  {
    try
    {
      out.close();
    }
    finally
    {
      lockFile.delete();
    }
  }
  
  public void write(int idx)
    throws IOException
  {
    out.write(idx);
  }
  
  public void write(char[] chr)
    throws IOException
  {
    out.write(chr);
  }
  
  public void write(char[] chr, int st, int end)
    throws IOException
  {
    out.write(chr, st, end);
  }
  
  public void write(String str)
    throws IOException
  {
    out.write(str);
  }
  
  public void write(String str, int st, int end)
    throws IOException
  {
    out.write(str, st, end);
  }
  
  public void flush()
    throws IOException
  {
    out.flush();
  }
}

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

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

public class NullOutputStream
  extends OutputStream
{
  public void write(byte[] b, int off, int len) {}
  
  public void write(int b) {}
  
  public void write(byte[] b)
    throws IOException
  {}
}

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

import java.io.Writer;

public class NullWriter
  extends Writer
{
  public void write(int idx) {}
  
  public void write(char[] chr) {}
  
  public void write(char[] chr, int st, int end) {}
  
  public void write(String str) {}
  
  public void write(String str, int st, int end) {}
  
  public void flush() {}
  
  public void close() {}
}

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

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

public class ProxyOutputStream
  extends FilterOutputStream
{
  public ProxyOutputStream(OutputStream proxy)
  {
    super(proxy);
  }
  
  public void write(int idx)
    throws IOException
  {
    out.write(idx);
  }
  
  public void write(byte[] bts)
    throws IOException
  {
    out.write(bts);
  }
  
  public void write(byte[] bts, int st, int end)
    throws IOException
  {
    out.write(bts, st, end);
  }
  
  public void flush()
    throws IOException
  {
    out.flush();
  }
  
  public void close()
    throws IOException
  {
    out.close();
  }
}

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

import java.io.FilterWriter;
import java.io.IOException;
import java.io.Writer;

public class ProxyWriter
  extends FilterWriter
{
  public ProxyWriter(Writer proxy)
  {
    super(proxy);
  }
  
  public void write(int idx)
    throws IOException
  {
    out.write(idx);
  }
  
  public void write(char[] chr)
    throws IOException
  {
    out.write(chr);
  }
  
  public void write(char[] chr, int st, int end)
    throws IOException
  {
    out.write(chr, st, end);
  }
  
  public void write(String str)
    throws IOException
  {
    out.write(str);
  }
  
  public void write(String str, int st, int end)
    throws IOException
  {
    out.write(str, st, end);
  }
  
  public void flush()
    throws IOException
  {
    out.flush();
  }
  
  public void close()
    throws IOException
  {
    out.close();
  }
}

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

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

public class TeeOutputStream
  extends ProxyOutputStream
{
  protected OutputStream branch;
  
  public TeeOutputStream(OutputStream out, OutputStream branch)
  {
    super(out);
    this.branch = branch;
  }
  
  public synchronized void write(byte[] b)
    throws IOException
  {
    super.write(b);
    branch.write(b);
  }
  
  public synchronized void write(byte[] b, int off, int len)
    throws IOException
  {
    super.write(b, off, len);
    branch.write(b, off, len);
  }
  
  public synchronized void write(int b)
    throws IOException
  {
    super.write(b);
    branch.write(b);
  }
  
  public void flush()
    throws IOException
  {
    super.flush();
    branch.flush();
  }
  
  public void close()
    throws IOException
  {
    super.close();
    branch.close();
  }
}

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

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

public abstract class ThresholdingOutputStream
  extends OutputStream
{
  private int threshold;
  private long written;
  private boolean thresholdExceeded;
  
  public ThresholdingOutputStream(int threshold)
  {
    this.threshold = threshold;
  }
  
  public void write(int b)
    throws IOException
  {
    checkThreshold(1);
    getStream().write(b);
    written += 1L;
  }
  
  public void write(byte[] b)
    throws IOException
  {
    checkThreshold(b.length);
    getStream().write(b);
    written += b.length;
  }
  
  public void write(byte[] b, int off, int len)
    throws IOException
  {
    checkThreshold(len);
    getStream().write(b, off, len);
    written += len;
  }
  
  public void flush()
    throws IOException
  {
    getStream().flush();
  }
  
  public void close()
    throws IOException
  {
    try
    {
      flush();
    }
    catch (IOException ignored) {}
    getStream().close();
  }
  
  public int getThreshold()
  {
    return threshold;
  }
  
  public long getByteCount()
  {
    return written;
  }
  
  public boolean isThresholdExceeded()
  {
    return written > threshold;
  }
  
  protected void checkThreshold(int count)
    throws IOException
  {
    if ((!thresholdExceeded) && (written + count > threshold))
    {
      thresholdReached();
      thresholdExceeded = true;
    }
  }
  
  protected abstract OutputStream getStream()
    throws IOException;
  
  protected abstract void thresholdReached()
    throws IOException;
}

/* Location:
 * Qualified Name:     org.apache.commons.io.output.ThresholdingOutputStream
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
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-2017. Infinite Loop Ltd