List of usage examples for java.io OutputStream toString
public String toString()
From source file:Xtext2SonarM2T.launcher.popupMenus.AcceleoGenerateGenerateSonarQubePluginAction.java
private void copyFile(InputStream input, File output, String name) throws IOException { OutputStream outputStream = new FileOutputStream(output); int read = 0; byte[] bytes = new byte[1024]; while ((read = input.read(bytes)) != -1) { outputStream.write(bytes, 0, read); }// w w w . java2 s .c o m System.out.println("outputStream = " + outputStream.toString()); outputStream.close(); System.out.println("Copy Done!"); //updateNaming(output, name); //System.out.println("Update naming Done!"); }
From source file:org.jenkinsci.plugins.drupal.beans.DrushInvocation.java
/** * Get a list of test classes available. *///w w w. j a v a 2 s. c o m public Collection<DrupalTest> getTests() { ArgumentListBuilder args = getArgumentListBuilder(); args.add("test-run").add("--format=json"); OutputStream json = new ByteArrayOutputStream(); try { execute(args, new StreamTaskListener(json)); } catch (IOException e1) { listener.getLogger().println(e1); return CollectionUtils.EMPTY_COLLECTION; } catch (InterruptedException e2) { listener.getLogger().println(e2); return CollectionUtils.EMPTY_COLLECTION; } Collection<DrupalTest> tests = new HashSet<DrupalTest>(); JSONArray entries = (JSONArray) JSONValue.parse(json.toString()); if (entries == null) { listener.getLogger().println("[DRUPAL] Could not list available tests"); return CollectionUtils.EMPTY_COLLECTION; } for (Object entry : entries) { JSONObject test = (JSONObject) entry; tests.add(new DrupalTest(test.get("group").toString(), test.get("class").toString())); } return tests; }
From source file:org.jenkinsci.plugins.drupal.beans.DrushInvocation.java
/** * Get a map of projects installed on Drupal, keyed by machine name. */// w w w . jav a2 s . c o m public Map<String, DrupalExtension> getProjects(boolean modulesOnly, boolean enabledOnly) { ArgumentListBuilder args = getArgumentListBuilder(); args.add("pm-list").add("--pipe").add("--format=json"); if (modulesOnly) { args.add("--type=module"); } if (enabledOnly) { args.add("--status=enabled"); } OutputStream json = new ByteArrayOutputStream(); try { execute(args, new StreamTaskListener(json)); } catch (IOException e1) { listener.getLogger().println(e1); return MapUtils.EMPTY_MAP; } catch (InterruptedException e2) { listener.getLogger().println(e2); return MapUtils.EMPTY_MAP; } Map<String, DrupalExtension> projects = new HashMap<String, DrupalExtension>(); JSONObject entries = (JSONObject) JSONValue.parse(json.toString()); if (entries == null) { listener.getLogger().println("[DRUPAL] Could not list available projects"); return MapUtils.EMPTY_MAP; } for (Object name : entries.keySet()) { JSONObject entry = (JSONObject) entries.get(name); DrupalExtension project = new DrupalExtension(Objects.toString(name, ""), Objects.toString(entry.get("type"), ""), Objects.toString(entry.get("status"), ""), Objects.toString(entry.get("version"), "")); projects.put(name.toString(), project); } return projects; }
From source file:org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository.java
/** * Adds a set of properties as a locale properties file for the specified Domain ID * * @param domainId// w w w . j a v a2 s. co m * the domain ID for which this properties file will be added * @param locale * the locale for which this properties file will be added * @param properties * the properties to be added */ public void addLocalizationFile(final String domainId, final String locale, final Properties properties) throws DomainStorageException { // This is safe since ByteArray streams don't have to be closed if (null != properties) { try { final OutputStream out = new ByteArrayOutputStream(); properties.store(out, null); addLocalizationFile(domainId, locale, new ByteArrayInputStream(out.toString().getBytes()), true); } catch (IOException e) { throw new DomainStorageException( messages.getErrorString("PentahoMetadataDomainRepository.ERROR_0008_ERROR_IN_REPOSITORY", e.getLocalizedMessage()), e); } } }
From source file:com.cognitect.transit.TransitTest.java
public String write(Object o, TransitFactory.Format format) { try {//from w w w. j a va 2s . c o m OutputStream out = new ByteArrayOutputStream(); Writer w = TransitFactory.writer(format, out, null); w.write(o); return out.toString(); } catch (Throwable e) { throw new RuntimeException(e); } }
From source file:org.ebayopensource.turmeric.eclipse.utils.test.io.TestPropertiesFileUtil.java
/** * Test method for {@link org.ebayopensource.turmeric.eclipse.utils.io.PropertiesFileUtil#removePropertyByKey(java.io.InputStream, java.io.OutputStream, java.lang.String[])}. * @throws IOException // www. j a v a2s.co m */ @Test public void testRemovePropertyByKey() throws IOException { File tempFile = null; InputStream input = null; OutputStream output = null; try { tempFile = File.createTempFile("nikon", "d80"); output = new FileOutputStream(tempFile); Properties props = new Properties(); props.put("Nikon", "d80,d90,d700,d3s,d3x"); props.put("Canon", "5D Mark II"); props.store(output, "Comments"); IOUtils.closeQuietly(output); input = new FileInputStream(tempFile); String value = PropertiesFileUtil.getPropertyValueByKey(input, "Nikon"); Assert.assertNotNull(value); Assert.assertEquals("d80,d90,d700,d3s,d3x", value); output = new ByteArrayOutputStream(); PropertiesFileUtil.removePropertyByKey(input, output, new String[] { "Nikon" }); System.out.println("byte output: " + output.toString()); } finally { IOUtils.closeQuietly(output); IOUtils.closeQuietly(input); tempFile.delete(); } }
From source file:com.cognitect.transit.TransitTest.java
public void testRoundTrip() throws Exception { Object inObject = true;/*from w w w.j a v a 2 s . c o m*/ OutputStream out = new ByteArrayOutputStream(); Writer w = TransitFactory.writer(TransitFactory.Format.JSON_VERBOSE, out); w.write(inObject); String s = out.toString(); InputStream in = new ByteArrayInputStream(s.getBytes()); Reader reader = TransitFactory.reader(TransitFactory.Format.JSON, in); Object outObject = reader.read(); assertTrue(isEqual(inObject, outObject)); }
From source file:org.openiam.spml2.spi.example.ShellConnectorImpl.java
public ResponseType delete(DeleteRequestType reqType) { System.out.println("Delete called.."); String userName = null;/*from w w w . jav a 2s. c o m*/ String requestID = reqType.getRequestID(); /* PSO - Provisioning Service Object - * - ID must uniquely specify an object on the target or in the target's namespace * - Try to make the PSO ID immutable so that there is consistency across changes. */ PSOIdentifierType psoID = reqType.getPsoID(); userName = psoID.getID(); /* targetID - */ String targetID = psoID.getTargetID(); /* ContainerID - May specify the container in which this object should be created * ie. ou=Development, org=Example */ PSOIdentifierType containerID = psoID.getContainerID(); /* A) Use the targetID to look up the connection information under managed systems */ ManagedSys managedSys = managedSysService.getManagedSys(targetID); String host; String hostlogin; String hostpassword; host = managedSys.getHostUrl(); hostlogin = managedSys.getUserId(); hostpassword = managedSys.getDecryptPassword(); //powershell.exe -command "& C:\appserver\apache-tomcat-6.0.26\powershell\delete.ps1 principalName" StringBuffer strBuf = new StringBuffer(); strBuf.append("cmd /c powershell.exe -command \"& C:\\powershell\\ad\\Del-AdUser.ps1 "); strBuf.append("'" + host + "' "); strBuf.append("'" + userName + "' \" "); System.out.println("**Command line string= " + strBuf.toString()); try { //Runtime.getRuntime().exec(cmdarray); //exec(strBuf.toString()); Process p = Runtime.getRuntime().exec(strBuf.toString()); System.out.println("Process =" + p); OutputStream stream = p.getOutputStream(); System.out.println("stream=" + stream.toString()); } catch (Exception e) { e.printStackTrace(); } ResponseType respType = new ResponseType(); respType.setStatus(StatusCodeType.SUCCESS); return respType; }
From source file:org.openiam.spml2.spi.example.ShellConnectorImpl.java
public ResponseType setPassword(SetPasswordRequestType reqType) { log.debug("setPassword request called.."); String userName;/*w w w. ja v a 2 s . c o m*/ String requestID = reqType.getRequestID(); /* PSO - Provisioning Service Object - * - ID must uniquely specify an object on the target or in the target's namespace * - Try to make the PSO ID immutable so that there is consistency across changes. */ PSOIdentifierType psoID = reqType.getPsoID(); userName = psoID.getID(); /* targetID - */ String targetID = psoID.getTargetID(); /* ContainerID - May specify the container in which this object should be created * ie. ou=Development, org=Example */ PSOIdentifierType containerID = psoID.getContainerID(); /* A) Use the targetID to look up the connection information under managed systems */ ManagedSys managedSys = managedSysService.getManagedSys(targetID); String host; String hostlogin; String hostpassword; host = managedSys.getHostUrl(); hostlogin = managedSys.getUserId(); hostpassword = managedSys.getDecryptPassword(); StringBuffer strBuf = new StringBuffer(); strBuf.append("cmd /c powershell.exe -command \"& C:\\powershell\\ad\\SetPassword-UserActiveDir.ps1 "); strBuf.append("'" + host + "' "); strBuf.append("'" + hostlogin + "' "); strBuf.append("'" + hostpassword + "' "); strBuf.append("'" + userName + "' "); strBuf.append("'" + reqType.getPassword() + "' \" "); System.out.println("Command line string= " + strBuf.toString()); String[] cmdarray = { "cmd", strBuf.toString() }; try { //Runtime.getRuntime().exec(cmdarray); //exec(strBuf.toString()); Process p = Runtime.getRuntime().exec(strBuf.toString()); System.out.println("Process =" + p); OutputStream stream = p.getOutputStream(); System.out.println("stream=" + stream.toString()); } catch (Exception e) { e.printStackTrace(); } ResponseType respType = new ResponseType(); respType.setStatus(StatusCodeType.SUCCESS); return respType; }
From source file:com.comcast.cmb.test.tools.CNSTestingUtils.java
public static String doSetTopicAttributes(CNSControllerServlet cns, User user, OutputStream out, String attributeName, String attributeValue, String topicArn) throws Exception { SimpleHttpServletRequest request = new SimpleHttpServletRequest(); Map<String, String[]> params = new HashMap<String, String[]>(); addParam(params, "Action", "SetTopicAttributes"); if (topicArn != null) { addParam(params, "TopicArn", topicArn); }/*from w ww . jav a 2s . c o m*/ if (attributeName != null) { addParam(params, "AttributeName", attributeName); } if (attributeValue != null) { addParam(params, "AttributeValue", attributeValue); } addParam(params, "AWSAccessKeyId", user.getAccessKey()); request.setParameterMap(params); ((SimpleHttpServletRequest) request).setParameterMap(params); SimpleHttpServletResponse response = new SimpleHttpServletResponse(); response.setOutputStream(out); cns.doGet(request, response); response.getWriter().flush(); return out.toString(); }