| Author |
How to download a csv file through java without using input and output streams
|
Mani Sing
Greenhorn
Joined: Jun 30, 2010
Posts: 7
|
|
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
Joined: Oct 27, 2005
Posts: 19232
|
|
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.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Mani Sing
Greenhorn
Joined: Jun 30, 2010
Posts: 7
|
|
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
Joined: Oct 27, 2005
Posts: 19232
|
|
|
I doubt this is possible at all. I would really love to see the answer to this, if there is any.
|
 |
dasiydee indhu
Greenhorn
Joined: Mar 31, 2011
Posts: 1
|
|
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
Joined: Oct 27, 2005
Posts: 19232
|
|
|
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
Joined: Mar 22, 2000
Posts: 12327
|
|
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
|
Java Resources at www.wbrogden.com
|
 |
 |
|
|
subject: How to download a csv file through java without using input and output streams
|
|
|