• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to download a csv file through java without using input and output streams

 
Greenhorn
Posts: 7
Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI

Please help me,
How can i download a csv file through java without using input and output stream.
I want to download a csv file with the headers and followed by data.
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This question is similar to "how do I read a file without accessing the disk". The answer is: you can't. You may be able to wrap the InputStream in a Reader (hint: our AccessingFileFormats FAQ has a few links to libraries for parsing CSV files; I personally recommend opencsv) but in the end you'll still need an InputStream.

In case you don't know, InputStreamReader is the class to use to turn any InputStream into a Reader. To read from a file you have two choices:
1) use a FileReader, if the default encoding works out for you.
2) use a FileInputStream wrapped in an InputStreamReader if you need to explicitly specify the encoding.
 
Mani Sing
Greenhorn
Posts: 7
Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rob for the update....

Actually i juss want to download the csv file without using Streams at all. Basically it's a challenge question given by my Senior to me.
if any body can help it out please.

 
Rob Spoor
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I doubt this is possible at all. I would really love to see the answer to this, if there is any.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In case you don't know, InputStreamReader is the class to use to turn any InputStream into a Reader. To read from a file you have two choices:
1) use a FileReader, if the default encoding works out for you.
2) use a FileInputStream wrapped in an InputStreamReader if you need to explicitly specify the encoding.
 
Rob Spoor
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's part of my post; is there a problem with that? Don't you understand it? Or did you just want to repeat the significance?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suppose you could cheat and use Java to exec a separate process to download the file - possibly with FTP.

Or maybe you could hide the use of streams with something like the java.net.URLConnection getContent() method. (I have not idea if that would work, just speculating)

Bill

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic