on 03-28-2008 8:13 AM
Hi everybody,
how can I convert a String to OutputStream?
Thanks, Regards Mario
You have to convert String to OutputStream by means of using getBytes() method..
See the example
public void execute(InputStream inputstream, OutputStream outputstream) throws StreamTransformationException {
outputstream.write("<?xml version = '1.0' encoding = 'utf-8'>".getBytes());
outputstream.write(<ns0:outputinfo ns0=\urn:xyz\File_File\>".getBytes());
String newline=null;
BufferedReader br = new BufferedReader(new InputStreamReader(inputstream));
StringBuffer sb = new StringBuffer();
while(newline = br.readLine())!=null)
{
String empno=null;
String empname=null;
String native=null;
char[] chr = new char[100];
chr = newline.toCharArray();
String[] data = new String[10];
int a = 0;
int b = 2;
for(int i=0;i<newline.length(); i++)
{
if(chr<i>==',')
{
data[a]=newline.substring(b,i);
a=a+1;
b=i+1; }
empno=data[0];
empname=data[1];
native=data[2];
outputstream.write("<Data>".getBytes());
outputstream.write("<Record>".getBytes());
outputstream.write(("<EmpNo>"empno"</Empno>").getBytes());
outputstream.write(("<EmpName>"empname"</Empname>").getBytes());
outputstream.write(("<Native>"native"</Native>").getBytes());
outputstream.write(("</Record>".getBytes());
outputstream.write("</Data>".getBytes());
}
outputstream.write("</ns0:outputinfo>".getBytes());
}
br.close();
inputstream.close();
outputstream.close();
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi check the below links for reference
www.sap-img.com/java/java-2-notes.htm
note:reward points if solution found helpfull.....
regards
chandrakanth.k
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.