• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Mani Sing
Greenhorn
Posts: 7
Linux Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
 
Rob Spoor
Sheriff
Pie
Posts: 20661
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
Linux Ubuntu
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 20661
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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.
 
dasiydee indhu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 20661
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • 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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic