not able to convert outputstream to inputstream
807588Jul 20 2007 — edited Jan 20 2009Hi freinds plz help me on this i am not getting a solution for this
converting inputstream to outputstream
public ReportGenerator(Connection con,String input,OutputStream out){
try{
System.out.println("inside ReportGenerator()");
InputStream bais = new ByteArrayInputStream(input.getBytes());
JasperCompileManager.compileReportToStream (bais,out);
System.out.println("Afeter the compile");
bais = new ByteArrayInputStream(out.toString().getBytes());
//here its giving an error saying cant load Inputstream
JasperFillManager.fillReportToStream (bais,out,new HashMap(),con);
bais = new ByteArrayInputStream(out.toString().getBytes());
JasperExportManager.exportReportToPdfStream(bais,out);
}catch(Exception e){
e.printStackTrace();
}
so i tried using PipedStream for the same thing this is the code using piped streams
public ReportGenerator(Connection con,String input,OutputStream out){
try{
byte arrayOfByte[] = input.getBytes();
System.out.println("Storing the input into a byte array");
PipedInputStream pins = new PipedInputStream();
PipedOutputStream pouts = new PipedOutputStream(pins);
System.out.println("Storing the PipedInputStream into PipedOutputStream");
System.out.println("length === "+arrayOfByte.length);
//its giveing me the output till here and after this it is getting hanged so pls someone suggest a solution for this problem or send me the code.
pouts.write(arrayOfByte,0, arrayOfByte.length);
pins.connect(pouts);
JasperCompileManager.compileReportToStream(bias,out);
JasperFillManager.fillReportToStream(pins,out,new HashMap(),con);
JasperExportManager.exportReportToPdfStream (pins,out);
}catch(Exception e){
e.printStackTrace();
}
Thanks for your help