1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.apache.commons.net.io;
  17. import java.io.IOException;
  18. /**
  19. * The CopyStreamException class is thrown by the org.apache.commons.io.Util
  20. * copyStream() methods. It stores the number of bytes confirmed to
  21. * have been transferred before an I/O error as well as the IOException
  22. * responsible for the failure of a copy operation.
  23. * @see Util
  24. * @author <a href="mailto:savarese@apache.org">Daniel F. Savarese</a>
  25. * @version $Id: CopyStreamException.java,v 1.9 2004/02/29 10:26:55 scolebourne Exp $
  26. */
  27. public class CopyStreamException extends IOException
  28. {
  29. private long totalBytesTransferred;
  30. private IOException ioException;
  31. /**
  32. * Creates a new CopyStreamException instance.
  33. * @param message A message describing the error.
  34. * @param bytesTransferred The total number of bytes transferred before
  35. * an exception was thrown in a copy operation.
  36. * @param exception The IOException thrown during a copy operation.
  37. */
  38. public CopyStreamException(String message,
  39. long bytesTransferred,
  40. IOException exception)
  41. {
  42. super(message);
  43. totalBytesTransferred = bytesTransferred;
  44. ioException = exception;
  45. }
  46. /**
  47. * Returns the total number of bytes confirmed to have
  48. * been transferred by a failed copy operation.
  49. * @return The total number of bytes confirmed to have
  50. * been transferred by a failed copy operation.
  51. */
  52. public long getTotalBytesTransferred()
  53. {
  54. return totalBytesTransferred;
  55. }
  56. /**
  57. * Returns the IOException responsible for the failure of a copy operation.
  58. * @return The IOException responsible for the failure of a copy operation.
  59. */
  60. public IOException getIOException()
  61. {
  62. return ioException;
  63. }
  64. }