FilterOutputStream write - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for FilterOutputStream write method.

This code example shows how to use the following methods:write, putNextEntry, close, closeEntry
    assertEquals("hello", IOUtils.toString(in));
  } 
   
  private File makeTestJar() throws IOException {
    File jarFile = new File(testDir, "test.jar");
    JarOutputStream out = new JarOutputStream(new FileOutputStream(jarFile));
    ZipEntry entry = new ZipEntry("resource.txt");
    out.putNextEntry(entry);
    out.write("hello".getBytes());
    out.closeEntry();
    out.close();
    return jarFile;
  } 
   
} 
9
CodeRank
This code example shows how to use the following methods:close, write
    utilTest.checkUserDir();
    utilTest.redirectIfAntJunit();
  } 
 
  protected void createInput() throws IOException { 
    DataOutputStream out = new DataOutputStream(new FileOutputStream(INPUT_FILE.getAbsoluteFile()));
    out.write(input.getBytes("UTF-8"));
    out.close();
  } 
 
  protected String[] genArgs() {
    return new String[] {
      "-input", INPUT_FILE.getAbsolutePath(),
      "-output", OUTPUT_DIR.getAbsolutePath(),
      "-mapper", map,
      "-reducer", reduce,
      "-jobconf", "mapreduce.task.files.preserve.failedtasks=true", 
      "-jobconf", "stream.tmpdir="+System.getProperty("test.build.data","/tmp"),
      "-io", "typedbytes" 
    }; 
8
CodeRank
This code example shows how to use the following methods:writeInt, write
    app.go();
  } 
   
  private void writeString(String str) throws IOException {
    byte[] bytes = str.getBytes("UTF-8");
    dos.writeInt(bytes.length);
    dos.write(bytes);
  } 
   
  private void writeInt(int i) throws IOException {
    dos.writeInt(4);
    IntWritable iw = new IntWritable(i);
    iw.write(dos);
  } 
} 
7
CodeRank
This code example shows how to use the following methods:writeByte, writeInt, writeShort, write
This code example shows how to use the following methods:write, writeInt, writeUTF, write
This code example shows how to use the following methods:write, write
     * @throws IOException if the write throws, we pass it on 
     */ 
    private void writeObject(Object o) throws IOException {
      if (o instanceof Text) {
        Text to = (Text) o;
        out.write(to.getBytes(), 0, to.getLength());
      } else { 
        out.write(o.toString().getBytes(utf8));
      } 
    } 
 
    public synchronized void write(K key, V value)
      throws IOException { 
 
      boolean nullKey = key == null || key instanceof NullWritable;
      boolean nullValue = value == null || value instanceof NullWritable;
      if (nullKey && nullValue) {
        return; 
      } 
      if (!nullKey) {

7
CodeRank
This code example shows how to use the following methods:writeByte, writeInt, writeShort, write
	public int calcLength() { 
		return 12 + data.length;
	} 
 
	public void assemble(DataOutputStream out) throws IOException {
		out.writeByte(128 + subtype);
		out.writeByte(204);
		out.writeShort(2 + (data.length >> 2));
		out.writeInt(ssrc);
		out.writeInt(name);
		out.write(data);
	} 
} 
6
CodeRank
This code example shows how to use the following methods:write, close, closeEntry, putNextEntry
		fout.write(bytes);
		fout.close();
	} 
 
	public static void zipFileIntoNewZip(String fileToZip, String newZipFilePath) throws Exception {
		ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(newZipFilePath));
		ZipEntry dexEntry = new ZipEntry(getNameOfFileFromFullPath(fileToZip));
 
		zipOut.putNextEntry(dexEntry);
		 
		byte[] fileBytes = readFileAsBytes(fileToZip);
		zipOut.write(fileBytes);
		 
		zipOut.closeEntry();
		zipOut.close();
	} 
 
	private static String getNameOfFileFromFullPath(String filePath) {
		int lastSeparatorIndex = filePath.lastIndexOf("/");
		 
6
CodeRank
This code example shows how to use the following methods:writeBoolean, close, write
This code example shows how to use the following methods:write
        } 
    } 
 
    public void test_write$BII_Exception() throws IOException {
        Support_OutputStream sos = new Support_OutputStream(testLength);
        os = new FilterOutputStream(sos);
        byte[] buf = new byte[10];
 
        try { 
            os.write(buf, -1, 1);
            fail("IndexOutOfBoundsException expected.");
        } catch (IndexOutOfBoundsException e) {
            // Expected. 
        } 
 
        try { 
            os.write(buf, 0, -1);
            fail("IndexOutOfBoundsException expected.");
        } catch (IndexOutOfBoundsException e) {
            // Expected. 

6
CodeRank
write Method Overview
Writes b.length bytes to this output stream.
See Code Examples for other Java 8 FilterOutputStream Methods: