Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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
  • 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: 21999
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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
Ubuntu Linux
  • 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
Posts: 21999
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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.
 
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
Posts: 21999
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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?
 
Author and all-around good cowpoke
Posts: 13078
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

 
Ew. You guys are ugly with a capital UG. Here, maybe this tiny ad can help:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic