Solved

convert string to inputstream

Posted on 2001-09-11
5
401 Views
Last Modified: 2008-02-01
I have a String =" abcdefghij ......"

How can I put into an InputStream.

0
Comment
Question by:TLTEO
  • 3
  • 2
5 Comments
 

Author Comment

by:TLTEO
ID: 6475846
InputStream is=new StringBufferInputStream(strdata);

is deprecated.

What is the new way ??
0
 
LVL 6

Accepted Solution

by:
kotan earned 5 total points
ID: 6475849
Use String Reader,

InputStream is = new StringReader(strdata)
0
 
LVL 6

Expert Comment

by:kotan
ID: 6475850
According jdk docs,

StringBufferInputStream class does not properly convert characters into bytes. As of JDK 1.1, the preferred way to create a stream from a string is via the StringReader class.
0
 

Author Comment

by:TLTEO
ID: 6475863
tks vm . Cheers
0
 

Author Comment

by:TLTEO
ID: 6475962
wrong I am getting error

found   : java.io.StringReader
required: java.io.InputStream
InputStream certfis=new StringReader(strdata);
                    ^
cud you pls verify
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 51
couple of eclipse 5 46
jsp login check 12 42
Problem to Alipay 10 42
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question