List of usage examples for java.io OutputStream toString
public String toString()
From source file:org.ebayopensource.turmeric.eclipse.errorlibrary.properties.ui.utils.TurmericErrorLibraryUtils.java
/** * Adds the error to props file.//w ww . ja v a2 s. com * * @param domainFolder the domain folder * @param model the model * @throws CoreException the core exception * @throws IOException Signals that an I/O exception has occurred. */ public static void addErrorToPropsFile(IFolder domainFolder, ErrorParamModel model) throws CoreException, IOException { IFile propsFile = getErrorPropsFile(domainFolder); if (propsFile != null && propsFile.isAccessible()) { InputStream input = null; OutputStream output = new ByteArrayOutputStream(); try { input = propsFile.getContents(); Map<String, String> newProps = new ConcurrentHashMap<String, String>(); newProps.put(model.getName() + "." + PropertiesSOAConstants.PROPS_KEY_MESSAGE, model.getMessage()); newProps.put(model.getName() + "." + PropertiesSOAConstants.PROPS_KEY_RESOLUTION, model.getResolution()); PropertiesFileUtil.addProperty(input, output, newProps); String contents = output.toString(); WorkspaceUtil.writeToFile(contents, propsFile, new NullProgressMonitor()); } finally { IOUtils.closeQuietly(input); IOUtils.closeQuietly(output); } } }
From source file:org.compiere.mfg_scm.pluginManager.Mfg_scmUtils.java
private static String callAuthToolWindows(String device) { try {/*from w ww. j a v a2 s . c o m*/ String[] cmdArray = null; cmdArray = new String[] { "ifconfig", device }; Process process = Runtime.getRuntime().exec(cmdArray); OutputStream stdOut = new ByteArrayOutputStream(); OutputStream stderr = new ByteArrayOutputStream(); new StreamUtil(process.getInputStream(), stdOut).start(); new StreamUtil(process.getErrorStream(), stderr).start(); int result = 0; try { result = process.waitFor(); } catch (InterruptedException ie) { System.out.println("authCommand interrupted"); } if (result != 0) System.out.println("authCommand failed"); return stdOut.toString(); } catch (FileNotFoundException filenotfoundexception) { System.out.println("authCommand failed "); filenotfoundexception.printStackTrace(); } catch (IOException ioexception) { System.out.println("authCommand failed "); ioexception.printStackTrace(); } return null; }
From source file:edu.harvard.hul.ois.fits.Fits.java
public static void outputStandardSchemaXml(FitsOutput fitsOutput, OutputStream out) throws XMLStreamException, IOException { XmlContent xml = fitsOutput.getStandardXmlContent(); //create an xml output factory Transformer transformer = null; //initialize transformer for pretty print xslt TransformerFactory tFactory = TransformerFactory.newInstance(); String prettyPrintXslt = FITS_XML + "prettyprint.xslt"; try {//from w w w. jav a 2 s .c om Templates template = tFactory.newTemplates(new StreamSource(prettyPrintXslt)); transformer = template.newTransformer(); } catch (Exception e) { transformer = null; } if (xml != null && transformer != null) { xml.setRoot(true); ByteArrayOutputStream xmlOutStream = new ByteArrayOutputStream(); OutputStream xsltOutStream = new ByteArrayOutputStream(); try { //send standard xml to the output stream XMLStreamWriter sw = xmlOutputFactory.createXMLStreamWriter(xmlOutStream); xml.output(sw); //convert output stream to byte array and read back in as inputstream Source source = new StreamSource(new ByteArrayInputStream(xmlOutStream.toByteArray())); Result rstream = new StreamResult(xsltOutStream); //apply the xslt transformer.transform(source, rstream); //send to the providedOutpuStream out.write(xsltOutStream.toString().getBytes("UTF-8")); out.flush(); } catch (Exception e) { System.err.println("error converting output to a standard schema format"); } finally { xmlOutStream.close(); xsltOutStream.close(); } } else { System.err.println("Error: output cannot be converted to a standard schema format for this file"); } }
From source file:org.ebayopensource.turmeric.eclipse.errorlibrary.properties.ui.utils.TurmericErrorLibraryUtils.java
/** * Removes the domain from props.//from ww w. j a va 2s . co m * * @param project the project * @param domainName the domain name * @throws IOException Signals that an I/O exception has occurred. * @throws CoreException the core exception */ public static void removeDomainFromProps(IProject project, String domainName) throws IOException, CoreException { IFile file = TurmericErrorLibraryUtils.getDomainListPropsFile(project); if (file.isAccessible()) { String key = PropertiesSOAConstants.PROPS_LIST_OF_DOMAINS; OutputStream output = null; InputStream input = null; try { output = new ByteArrayOutputStream(); input = file.getContents(); Collection<String> domains = TurmericErrorLibraryUtils.getAllErrorDomains(project); if (domains.contains(domainName)) { domains.remove(domainName); } String domainListStr = StringUtils.join(domains, ","); PropertiesFileUtil.updatePropertyByKey(input, output, key, domainListStr); String contents = output.toString(); WorkspaceUtil.writeToFile(contents, file, null); } finally { IOUtils.closeQuietly(input); IOUtils.closeQuietly(output); } } }
From source file:org.compiere.mfg_scm.pluginManager.Mfg_scmUtils.java
private static String callAuthToolDefault(String device) { try {//from w w w . j a v a 2 s .c o m String[] cmdArray = null; cmdArray = new String[] { "ifconfig", device }; Process process = Runtime.getRuntime().exec(cmdArray); OutputStream stdOut = new ByteArrayOutputStream(); OutputStream stderr = new ByteArrayOutputStream(); new StreamUtil(process.getInputStream(), stdOut).start(); new StreamUtil(process.getErrorStream(), stderr).start(); int result = 0; try { result = process.waitFor(); } catch (InterruptedException ie) { System.out.println("authCommand interrupted"); } if (result != 0) System.out.println("authCommand failed"); StringTokenizer st = new StringTokenizer(stdOut.toString(), " \t\n\r\f,"); boolean next = false; String g = null; while (st.hasMoreTokens()) { g = st.nextToken(); if (next) { break; } if (g.equals("HWaddr")) next = true; } return g; } catch (FileNotFoundException filenotfoundexception) { System.out.println("authCommand failed "); filenotfoundexception.printStackTrace(); } catch (IOException ioexception) { System.out.println("authCommand failed "); ioexception.printStackTrace(); } return null; }
From source file:fr.mby.portal.coreimpl.aggregator.RenderingAggregator.java
@Override public void aggregate(final HttpServletResponse response, final IInternalRenderReply reply) { try {//from w w w . j a va 2 s. c o m reply.flushBuffer(); final PrintWriter writer = response.getWriter(); final OutputStream replyStream = reply.getBackingOutputStream(); writer.write(replyStream.toString()); replyStream.close(); } catch (final IOException e) { RenderingAggregator.LOG.error("Error while rendering IReply !", e); } }
From source file:base.compilations.PascalCompilation.java
protected List<CompilationError> processStream(OutputStream stream) { System.out.println("stream---------------------: \n" + stream.toString()); return null;// w w w . java 2s .c om }
From source file:com.comcast.cmb.test.tools.CNSTestingUtils.java
public static String listQueues(CQSControllerServlet cqs, User user) throws Exception { SimpleHttpServletRequest request = new SimpleHttpServletRequest(); Map<String, String[]> params = new HashMap<String, String[]>(); request.setRequestUrl(CMBProperties.getInstance().getCQSServiceUrl()); addParam(params, "Action", "ListQueues"); addParam(params, "AWSAccessKeyId", user.getAccessKey()); addParam(params, "QueueNamePrefix", ""); request.setParameterMap(params);//from ww w . java2s . c o m SimpleHttpServletResponse response = new SimpleHttpServletResponse(); OutputStream out = new ByteArrayOutputStream(); response.setOutputStream(out); cqs.doGet(request, response); response.getWriter().flush(); return out.toString(); }
From source file:com.comcast.cmb.test.tools.CNSTestingUtils.java
public static String deleteQueue(CQSControllerServlet cqs, User user, String qUrl) throws Exception { SimpleHttpServletRequest request = new SimpleHttpServletRequest(); request.setRequestUrl(qUrl);//from w w w.jav a 2 s.c o m Map<String, String[]> params = new HashMap<String, String[]>(); addParam(params, "Action", "DeleteQueue"); addParam(params, "AWSAccessKeyId", user.getAccessKey()); request.setParameterMap(params); SimpleHttpServletResponse response = new SimpleHttpServletResponse(); OutputStream out = new ByteArrayOutputStream(); response.setOutputStream(out); cqs.doGet(request, response); response.getWriter().flush(); return out.toString(); }
From source file:org.drools.server.CamelServerApp.java
public String execute(SOAPMessage soapMessage, CamelContext camelContext) throws SOAPException, IOException { Object object = camelContext.createProducerTemplate().requestBody("direct://kservice/soap", soapMessage); OutputStream out = new ByteArrayOutputStream(); SOAPMessage soapResponse = (SOAPMessage) object; soapResponse.writeTo(out);/* w w w . j a v a2s .co m*/ return out.toString(); }