Example usage for java.io PrintStream PrintStream

List of usage examples for java.io PrintStream PrintStream

Introduction

In this page you can find the example usage for java.io PrintStream PrintStream.

Prototype

public PrintStream(OutputStream out, boolean autoFlush, Charset charset) 

Source Link

Document

Creates a new print stream, with the specified OutputStream, automatic line flushing and charset.

Usage

From source file:com.sap.prd.mobile.ios.mios.FatLibAnalyzer.java

private String getDetailedLipoInfo() throws IOException {
    final String defaultCharSet = Charset.defaultCharset().name();
    ByteArrayOutputStream byteOs = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(byteOs, true, defaultCharSet);
    try {//w w w.  ja v  a 2 s  .c om
        Forker.forkProcess(ps, null, "lipo", "-detailed_info", fatLib.getAbsolutePath());

        return new String(byteOs.toByteArray(), defaultCharSet);
    } finally {
        IOUtils.closeQuietly(ps);
    }
}

From source file:com.sap.prd.mobile.ios.mios.EffectiveBuildSettings.java

private static Properties extractBuildSettings(final IXCodeContext context) throws XCodeException {
    List<String> buildActions = Collections.emptyList();
    IOptions options = context.getOptions();
    Map<String, String> managedOptions = new HashMap<String, String>(options.getManagedOptions());
    managedOptions.put(Options.ManagedOption.SHOWBUILDSETTINGS.getOptionName(), null);

    XCodeContext showBuildSettingsContext = new XCodeContext(buildActions, context.getProjectRootDirectory(),
            context.getOut(),/*from  w w  w .j  a  v  a 2 s  .c  o  m*/
            new Settings(context.getSettings().getUserSettings(), context.getSettings().getManagedSettings()),
            new Options(options.getUserOptions(), managedOptions));

    final CommandLineBuilder cmdLineBuilder = new CommandLineBuilder(showBuildSettingsContext);
    PrintStream out = null;
    ByteArrayOutputStream os = null;
    try {
        os = new ByteArrayOutputStream();
        out = new PrintStream(os, true, Charset.defaultCharset().name());

        final int returnValue = Forker.forkProcess(out, context.getProjectRootDirectory(),
                cmdLineBuilder.createBuildCall());

        if (returnValue != 0) {
            if (out != null)
                out.flush();
            throw new XCodeException(
                    "Could not execute xcodebuild -showBuildSettings command for configuration "
                            + context.getConfiguration() + " and sdk " + context.getSDK() + ": "
                            + new String(os.toByteArray(), Charset.defaultCharset().name()));
        }

        out.flush();
        Properties prop = new Properties();
        prop.load(new ByteArrayInputStream(os.toByteArray()));
        return prop;

    } catch (IOException ex) {
        throw new XCodeException("Cannot extract build properties: " + ex.getMessage(), ex);
    } finally {
        IOUtils.closeQuietly(out);
    }
}