Search in sources :

Example 26 with OutputStreamWriter

use of java.io.OutputStreamWriter in project checkstyle by checkstyle.

the class XMLLogger method setOutputStream.

/**
     * Sets the OutputStream.
     * @param outputStream the OutputStream to use
     **/
private void setOutputStream(OutputStream outputStream) {
    final OutputStreamWriter osw = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
    writer = new PrintWriter(osw);
}
Also used : OutputStreamWriter(java.io.OutputStreamWriter) PrintWriter(java.io.PrintWriter)

Example 27 with OutputStreamWriter

use of java.io.OutputStreamWriter in project buck by facebook.

the class GenerateCodeCoverageReportStep method saveParametersToPropertyStream.

@VisibleForTesting
void saveParametersToPropertyStream(ProjectFilesystem filesystem, Set<Path> extractedClassesDirectories, OutputStream outputStream) throws IOException {
    final Properties properties = new Properties();
    properties.setProperty("jacoco.output.dir", filesystem.resolve(outputDirectory).toString());
    properties.setProperty("jacoco.exec.data.file", JACOCO_EXEC_COVERAGE_FILE);
    properties.setProperty("jacoco.format", format.toString().toLowerCase());
    properties.setProperty("jacoco.title", title);
    properties.setProperty("classes.jars", formatPathSet(jarFiles));
    properties.setProperty("classes.dir", formatPathSet(extractedClassesDirectories));
    properties.setProperty("src.dir", Joiner.on(":").join(sourceDirectories));
    if (coverageIncludes.isPresent()) {
        properties.setProperty("jacoco.includes", coverageIncludes.get());
    }
    if (coverageExcludes.isPresent()) {
        properties.setProperty("jacoco.excludes", coverageExcludes.get());
    }
    try (Writer writer = new OutputStreamWriter(outputStream, "utf8")) {
        properties.store(writer, "Parameters for Jacoco report generator.");
    }
}
Also used : OutputStreamWriter(java.io.OutputStreamWriter) Properties(java.util.Properties) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 28 with OutputStreamWriter

use of java.io.OutputStreamWriter in project buck by facebook.

the class WorkerProcess method ensureLaunchAndHandshake.

public synchronized void ensureLaunchAndHandshake() throws IOException {
    if (handshakePerformed) {
        return;
    }
    LOG.debug("Starting up process %d using command: \'%s\'", this.hashCode(), Joiner.on(' ').join(processParams.getCommand()));
    launchedProcess = executor.launchProcess(processParams);
    JsonWriter processStdinWriter = new JsonWriter(new BufferedWriter(new OutputStreamWriter(launchedProcess.getOutputStream())));
    JsonReader processStdoutReader = new JsonReader(new BufferedReader(new InputStreamReader(launchedProcess.getInputStream())));
    protocol = new WorkerProcessProtocolZero(executor, launchedProcess, processStdinWriter, processStdoutReader, stdErr);
    int messageID = currentMessageID.getAndAdd(1);
    LOG.debug("Sending handshake to process %d", this.hashCode());
    protocol.sendHandshake(messageID);
    LOG.debug("Receiving handshake from process %d", this.hashCode());
    protocol.receiveHandshake(messageID);
    handshakePerformed = true;
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) JsonReader(com.google.gson.stream.JsonReader) OutputStreamWriter(java.io.OutputStreamWriter) JsonWriter(com.google.gson.stream.JsonWriter) BufferedWriter(java.io.BufferedWriter)

Example 29 with OutputStreamWriter

use of java.io.OutputStreamWriter in project pinot by linkedin.

the class ControllerTest method postQuery.

public JSONObject postQuery(String query, String brokerBaseApiUrl) throws Exception {
    final JSONObject json = new JSONObject();
    json.put("pql", query);
    json.put("trace", isTraceEnabled);
    //    json.put("debugOptions", "routingOptions=FORCE_LLC,FORCE_HLC;otherOption=foo,bar");
    final long start = System.currentTimeMillis();
    final URLConnection conn = new URL(brokerBaseApiUrl + "/query").openConnection();
    conn.setDoOutput(true);
    final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream(), "UTF-8"));
    final String reqStr = json.toString();
    writer.write(reqStr, 0, reqStr.length());
    writer.flush();
    JSONObject ret = getBrokerReturnJson(conn);
    final long stop = System.currentTimeMillis();
    LOGGER.debug("Time taken for '{}':{}ms", query, (stop - start));
    return ret;
}
Also used : JSONObject(org.json.JSONObject) OutputStreamWriter(java.io.OutputStreamWriter) HttpURLConnection(java.net.HttpURLConnection) URLConnection(java.net.URLConnection) URL(java.net.URL) BufferedWriter(java.io.BufferedWriter)

Example 30 with OutputStreamWriter

use of java.io.OutputStreamWriter in project Signal-Android by WhisperSystems.

the class SmilXmlSerializer method serialize.

public static void serialize(SMILDocument smilDoc, OutputStream out) {
    try {
        Writer writer = new BufferedWriter(new OutputStreamWriter(out, "UTF-8"), 2048);
        writeElement(writer, smilDoc.getDocumentElement());
        writer.flush();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) BufferedWriter(java.io.BufferedWriter)

Aggregations

OutputStreamWriter (java.io.OutputStreamWriter)3616 IOException (java.io.IOException)1453 FileOutputStream (java.io.FileOutputStream)1408 BufferedWriter (java.io.BufferedWriter)1320 Writer (java.io.Writer)939 File (java.io.File)912 PrintWriter (java.io.PrintWriter)589 InputStreamReader (java.io.InputStreamReader)510 OutputStream (java.io.OutputStream)507 BufferedReader (java.io.BufferedReader)426 ByteArrayOutputStream (java.io.ByteArrayOutputStream)373 InputStream (java.io.InputStream)255 URL (java.net.URL)242 HttpURLConnection (java.net.HttpURLConnection)208 FileNotFoundException (java.io.FileNotFoundException)207 Test (org.junit.Test)201 ArrayList (java.util.ArrayList)198 Path (org.apache.hadoop.fs.Path)194 UnsupportedEncodingException (java.io.UnsupportedEncodingException)169 FileInputStream (java.io.FileInputStream)167