Copies the InputStream into the OutputStream, until the end of the stream has been reached. This method uses a buffer of 4096 kbyte. : Copy « File Input Output « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » File Input Output » CopyScreenshots 
Copies the InputStream into the OutputStream, until the end of the stream has been reached. This method uses a buffer of 4096 kbyte.
  
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/* 
 * JCommon : a free general purpose class library for the Java(tm) platform
 
 *
 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
 
 * Project Info:  http://www.jfree.org/jcommon/index.html
 *
 * This library is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU Lesser General Public License as published by 
 * the Free Software Foundation; either version 2.1 of the License, or 
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
 * USA.  
 *
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
 * in the United States and other countries.]
 
 * ------------
 * IOUtils.java
 * ------------
 * (C)opyright 2002-2004, by Thomas Morgner and Contributors.
 *
 * Original Author:  Thomas Morgner;
 * Contributor(s):   David Gilbert (for Object Refinery Limited);
 *
 * $Id: IOUtils.java,v 1.8 2009/01/22 08:34:58 taqua Exp $
 *
 * Changes
 * -------
 * 26-Jan-2003 : Initial version
 * 23-Feb-2003 : Documentation
 * 25-Feb-2003 : Fixed Checkstyle issues (DG);
 * 29-Apr-2003 : Moved to jcommon
 * 04-Jan-2004 : Fixed JDK 1.2.2 issues with createRelativeURL;
 *               added support for query strings within these urls (TM);
 */


/**
 * The IOUtils provide some IO related helper methods.
 *
 @author Thomas Morgner.
 */
public class Main {
  /**
   * Copies the InputStream into the OutputStream, until the end of the stream
   * has been reached. This method uses a buffer of 4096 kbyte.
   *
   @param in the inputstream from which to read.
   @param out the outputstream where the data is written to.
   @throws IOException if a IOError occurs.
   */
  public void copyStreams(final InputStream in, final OutputStream out)
      throws IOException {
      copyStreams(in, out, 4096);
  }
  /**
   * Copies the InputStream into the OutputStream, until the end of the stream
   * has been reached.
   *
   @param in the inputstream from which to read.
   @param out the outputstream where the data is written to.
   @param buffersize the buffer size.
   @throws IOException if a IOError occurs.
   */
  public void copyStreams(final InputStream in, final OutputStream out, 
          final int buffersizethrows IOException {
      // create a 4kbyte buffer to read the file
      final byte[] bytes = new byte[buffersize];

      // the input stream does not supply accurate available() data
      // the zip entry does not know the size of the data
      int bytesRead = in.read(bytes);
      while (bytesRead > -1) {
          out.write(bytes, 0, bytesRead);
          bytesRead = in.read(bytes);
      }
  }
}

   
    
  
Related examples in the same category
1. Copies file contents from source to destination
2. Copies the contents of the given InputStream to the given OutputStream
3. Copy Pipe
4. Copy any input stream to output file
5. Copy any input stream to output stream
6. Copy file and directory
7. Utility methods for file and stream copying
8. Copies all data from an input stream to an output stream.
9. copy Completely (InputStream input, OutputStream output)
10. copy Completely (Reader input, Writer output)
11. copy Completely(URI input, URI output)
12. Copies the InputStream into the OutputStream, until the end of the stream has been reached.
13. Copies the contents of the Reader into the Writer, until the end of the stream has been reached.
14. Copies the contents of the Reader into the Writer, until the end of the stream has been reached. This method uses a buffer of 4096 kbyte.
15. Copy a file and user buffer
16. Copy a directory and all of its contents.
17. Copy chars from a Reader to a Writer.
18. Copy in stream to an out stream
19. Copy the source file system structure into the supplied target location.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.