Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 23rd, 2012, 12:59 PM
Registered User
 
Join Date: Feb 2012
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to write download results to a file

Hi all,

How can I change the following to allow me to also write the results to a file instead of the console.

Code:
InputStream inputStream = generalQuery.run(ReportFormat.CSV);

            
            // Writing the output to console
            byte[] buffer = new byte[1024];
            int length = 0;

            
         // Print generated report
            while((length = inputStream.read(buffer)) != -1) {
                System.out.write(buffer, 0, length); 
                
                
            }
        }
        catch(DartException ex) {
            System.out.println(ex.getMessage());
            ex.printStackTrace();
        }
        catch(IOException ex) {
            System.out.println(ex.getMessage());
            ex.printStackTrace();
        }
Thanks















Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to write a script to download file Ivanchan Other Programming Languages 0 January 24th, 2008 05:56 AM
write to file angelboy C# 2005 4 March 25th, 2007 05:01 AM
write file abaso.jadhav01 ASP.NET 2.0 Basics 0 November 24th, 2006 06:15 PM
Smaller download/single download file available jminatel BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 November 21st, 2005 11:10 AM
reading HTML from file -> write to file mikeuk Beginning PHP 4 July 21st, 2004 05:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.