• Post Reply Bookmark Topic Watch Topic
  • New Topic

HTTPResponse into a File  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I read HTTP response object and write it to a file? It is easier to write a text file, I wanted the program to be able to read the response and create an appropriate file depending on the content, if its jpg it should save a jpg, if its PDF it should save as PDF and so on.

thanks much
 
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Check the content type to determine the type of file.
2) Copy the contents directly using InputStream and FileOutputStream.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!