Convert InputStream to String?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Convert InputStream to String?

  1. #1
    Join Date
    Oct 2005
    Posts
    10

    Convert InputStream to String?

    Is there a simple way to do this other than doing it line-by-line? I'm not sure how type casting works in Java. Below is some code I'm working on.
    Code:
    InputStream in = s.getInputStream();
    String s;

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,474

    Re: Convert InputStream to String?

    Is there a simple way to do this other than doing it line-by-line?
    Is there a simple way to do what exactly - please explain clearly what you want to do.
    Below is some code I'm working on.
    Are you being serious? You've provided 2 lines of code without any explanation as to what it's supposed to do. The second line is declaring the variable s which you have already used in the first line. You are calling a method getInputStream() which isn't in the String class, so what type is s.

  3. #3
    Join Date
    Jun 1999
    Location
    SW Missouri
    Posts
    3,436

    Re: Convert InputStream to String?

    If by convert you mean to "read" Strings from an InputStream. Wrap the InputStream in a reader and then in a BufferedReader and use its readLine() method.
    Norm

  4. #4
    Join Date
    Jul 2005
    Location
    Currently in Mexico City
    Posts
    566

    Re: Convert InputStream to String?

    PHP Code:
    BufferedReader br = new BufferedReader(new InputStreamReader(is)); 
    Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?

    I had a nightmare last night. I was dreaming that Iím 64-bit and my blanket is 32-bit and I couldnít cover myself with it, so Iíve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S (from: bash.org.ru)

    //always looking for job opportunities in AU/NZ/US/CA/Europe :P
    willCodeForFood(Arrays.asList("Java","PHP","C++","bash","Assembler","XML","XHTML","CSS","JS","PL/SQL"));

    USE [code] TAGS! Read this FAQ if you are new here. If this post was helpful, please rate it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center