Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

PrintStream cannot be resolved to a type

I'm working on a component (based on this) which redirects all output into a string. See my code below. When I try to import the component into a job and hit the run button, java complains about not being able to resolve PrintStream to a type. How should I fix this?

Maybe I should provide a bit more detais. It would be great if I can capture all STDOUT and ERR into a string and at the end of the Talend job email that string to someone.
<%@ jet 
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.core.model.metadata.IMetadataTable
org.talend.core.model.metadata.IMetadataColumn
org.talend.core.model.process.IConnection
org.talend.core.model.process.IConnectionCategory
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.metadata.types.JavaTypesManager
org.talend.core.model.metadata.types.JavaType
java.util.List
java.util.Map
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();

boolean redirectOut = ("true").equals(ElementParameterParser.getValue(node, "__SYSTEMOUT__"));
String appendOut = ((String)ElementParameterParser.getValue(node, "__APPENDSYSTEMOUT__"));
boolean redirectErr = ("true").equals(ElementParameterParser.getValue(node, "__SYSTEMERR__"));
String appendErr = ((String)ElementParameterParser.getValue(node, "__APPENDSYSTEMERR__"));
boolean outputDate = ("true").equals(ElementParameterParser.getValue(node, "__OUTPUTDATE__"));
String dateCaption = ((String)ElementParameterParser.getValue(node, "__DATECAPTION__"));
if (redirectOut) {
String fileOut = ElementParameterParser.getValue(node, "__SYSTEMOUTFILE__");
%>

ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new java.io.PrintStream(baos);
System.setOut(ps);

<%
}
%>
Labels (4)
1 Reply
Anonymous
Not applicable
Author

Change the code:
PrintStream ps = new java.io.PrintStream(baos);

to the code:
java.io.PrintStream ps = new java.io.PrintStream(baos);