Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

convert from string to inputstream  RSS feed

 
usha mocherla
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am new user of java.
Can anybody help me in changing from string to InputStream.
This is following code:
String inputstream=request.getParameter("inputstream");
InputStream in=request.getParameter("inputstream");
It gives error "cannot convert from string to InputStream"
Plz help me.
Regards
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was just discussed in the intermediate forum
 
Timmy Marks
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that request is an instance of HttpServletRequest, the method getParameter() returns a String, in the line
InputStream in=request.getParameter("inputstream");
you are trying to cast the String into an InputStream. If you want an InputStream from request, you have to call the getInputStream() method inherited from ServletRequest.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!