Java 8 OutputStreamWriter - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 OutputStreamWriter class.

This code example shows how to use the following methods:flush, write
 
  @Override 
  public void writeTo(JSONStreamAware jsonStreamAware, Class<?> aClass, Type type, Annotation[] annotations,
                      MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap,
                      OutputStream outputStream) throws IOException, WebApplicationException {
    Writer writer = new OutputStreamWriter(outputStream);
    jsonStreamAware.writeJSONString(writer);
    writer.write(ENTER);
    writer.flush();
  } 
 
} 
9
CodeRank
This code example shows how to use the following methods:close, write
      return null; 
    } 
    File historyFile = new File(historyRoot, "history-" + System.currentTimeMillis() + ".csv");
    OutputStreamWriter out = null;
    try { 
      out = new OutputStreamWriter(new FileOutputStream(historyFile), Charset.forName("UTF-8"));
      out.write(history);
      return Uri.parse("file://" + historyFile.getAbsolutePath());
    } catch (IOException ioe) {
      Log.w(TAG, "Couldn't access file " + historyFile + " due to " + ioe);
      return null; 
    } finally { 
      if (out != null) {
        try { 
          out.close();
        } catch (IOException ioe) {
          // do nothing 
        } 
      } 
    } 
8
CodeRank
This code example shows how to use the following methods:close, write
public class TestJobName extends ClusterMapReduceTestCase { 
 
  public void testComplexName() throws Exception { 
    OutputStream os = getFileSystem().create(new Path(getInputDir(),
        "text.txt")); 
    Writer wr = new OutputStreamWriter(os);
    wr.write("b a\n");
    wr.close();
 
    JobConf conf = createJobConf();
    conf.setJobName("[name][some other value that gets truncated internally that this test attempts to aggravate]");
 
    conf.setInputFormat(TextInputFormat.class);
 
    conf.setOutputKeyClass(LongWritable.class);
    conf.setOutputValueClass(Text.class);
 
    conf.setMapperClass(IdentityMapper.class);
 
    FileInputFormat.setInputPaths(conf, getInputDir());
8
CodeRank
This code example shows how to use the following methods:
        return true; 
    } 
 
    public void writeTo(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4,
            MultivaluedMap<String, Object> arg5, OutputStream arg6) throws IOException, WebApplicationException {
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(arg6));
        bw.write(arg0.toString());
        bw.flush();
    } 
} 
8
CodeRank
This code example shows how to use the following methods:close
                String encoding = params.getProperty("encoding");
                 
                response.setCharacterEncoding(encoding != null ? encoding : "UTF-8");
                Writer writer = encoding == null ?
                    response.getWriter() :
                    new OutputStreamWriter(response.getOutputStream(), encoding);
                 
                ((WriterExporter) exporter).export(project, params, engine, writer);
                writer.close();
            } else if (exporter instanceof StreamExporter) {
                response.setCharacterEncoding("UTF-8");
                 
                OutputStream stream = response.getOutputStream();
                ((StreamExporter) exporter).export(project, params, engine, stream);
                stream.close();
//          } else if (exporter instanceof UrlExporter) { 
//              ((UrlExporter) exporter).export(project, options, engine); 
            } else { 
                // TODO: Should this use ServletException instead of respondException? 
                respondException(response, new RuntimeException("Unknown exporter type"));
8
CodeRank
This code example shows how to use the following methods:flush, write
 
  @Override 
  public void writeTo(Map map, Class<?> aClass, Type type, Annotation[] annotations,
                      MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap,
                      OutputStream outputStream) throws IOException, WebApplicationException {
    Writer writer = new OutputStreamWriter(outputStream);
    JSONObject.writeJSONString(map, writer);
    writer.write(ENTER);
    writer.flush();
  } 
 
} 
9
CodeRank
This code example shows how to use the following methods:flush, write
                        final Annotation[] annotations,
                        final MediaType mediaType,
                        final MultivaluedMap<String, Object> headers,
                        final OutputStream stream) throws IOException, WebApplicationException {
 
        OutputStreamWriter writer = new OutputStreamWriter(stream);
        writer.write(entity.getName());
        writer.write('=');
        writer.write(entity.getValue());
        writer.write('\n');
        writer.flush();
    } 
 
} 
8
CodeRank
This code example shows how to use the following methods:close, write
    fs.delete(INPUT_DIR, true);
    fs.delete(OUTPUT_DIR, true);
 
    OutputStream os = fs.create(INPUT_FILE);
 
    Writer wr = new OutputStreamWriter(os);
    wr.write("hello1\n");
    wr.write("hello2\n");
    wr.write("hello3\n");
    wr.write("hello4\n");
    wr.close();
  } 
 
  public void testMapReduceJob() throws Exception { 
 
    JobConf conf = new JobConf(TestUserDefinedCounters.class);
    conf.setJobName("UserDefinedCounters");
     
    FileSystem fs = FileSystem.get(conf);
    cleanAndCreateInput(fs);
8
CodeRank
This code example shows how to use the following methods:flush, write
            Annotation annotations[],
            MediaType mediaType,
            MultivaluedMap<String, Object> httpHeaders,
            OutputStream entityStream) throws IOException {
        try { 
            OutputStreamWriter writer = new OutputStreamWriter(entityStream,
                    getCharset(mediaType));
            t.write(writer);
            writer.write("\n");
            writer.flush();
        } catch (JSONException je) {
            throw new WebApplicationException( 
                    new Exception(LocalizationMessages.ERROR_WRITING_JSON_ARRAY(), je),
                    500); 
        } 
    } 
} 
8
CodeRank
This code example shows how to use the following methods:
            // Expected data is "dummy request#" 
            len = input.read(b);
            if (len > 0) {
                String data = new String(b, 0, len);
                if (data.endsWith("#")) {
                    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(handler.getWebConnection().getOutputStream()));
                    writeLine(writer, "isPostConstructCallbackInvoked: " + handler.isPostConstructCallbackInvoked());
                    writeLine(writer, "isInjectionOk: " + handler.isInjectionOk());
                    writeLine(writer, "isInterceptorInvoked: " + isInterceptorInvoked());
                    writeLine(writer, "END");
                    writer.flush();
                } 
            } else { 
                System.out.println("Data length: " + len);
            } 
        } 
    } 
 
    private boolean isInterceptorInvoked() { 
        List<Interception> interceptions = ComponentInterceptor.getInterceptions();
8
CodeRank

Related Java 8 OutputStreamWriter Questions & Answers:

See Code Examples for Java 8 OutputStreamWriter Methods: