001 /* 002 * Copyright 2001-2005 The Apache Software Foundation 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.apache.commons.net.io; 017 018 import java.io.IOException; 019 020 /** 021 * The CopyStreamException class is thrown by the org.apache.commons.io.Util 022 * copyStream() methods. It stores the number of bytes confirmed to 023 * have been transferred before an I/O error as well as the IOException 024 * responsible for the failure of a copy operation. 025 * @see Util 026 * @author <a href="mailto:savarese@apache.org">Daniel F. Savarese</a> 027 * @version $Id: CopyStreamException.java 165675 2005-05-02 20:09:55Z rwinston $ 028 */ 029 public class CopyStreamException extends IOException 030 { 031 private long totalBytesTransferred; 032 private IOException ioException; 033 034 /** 035 * Creates a new CopyStreamException instance. 036 * @param message A message describing the error. 037 * @param bytesTransferred The total number of bytes transferred before 038 * an exception was thrown in a copy operation. 039 * @param exception The IOException thrown during a copy operation. 040 */ 041 public CopyStreamException(String message, 042 long bytesTransferred, 043 IOException exception) 044 { 045 super(message); 046 totalBytesTransferred = bytesTransferred; 047 ioException = exception; 048 } 049 050 /** 051 * Returns the total number of bytes confirmed to have 052 * been transferred by a failed copy operation. 053 * @return The total number of bytes confirmed to have 054 * been transferred by a failed copy operation. 055 */ 056 public long getTotalBytesTransferred() 057 { 058 return totalBytesTransferred; 059 } 060 061 /** 062 * Returns the IOException responsible for the failure of a copy operation. 063 * @return The IOException responsible for the failure of a copy operation. 064 */ 065 public IOException getIOException() 066 { 067 return ioException; 068 } 069 }