List of usage examples for java.io FilterOutputStream FilterOutputStream
public FilterOutputStream(OutputStream out)
From source file:Main.java
public static void main(String[] args) throws Exception { // create input streams OutputStream os = new FileOutputStream("C://test.txt"); FilterOutputStream fos = new FilterOutputStream(os); // releases any system resources associated with the stream fos.close();//from w ww .j a v a2 s. co m // writes byte to the output stream fos.write(65); }
From source file:Main.java
public static void main(String[] args) throws Exception { OutputStream os = new FileOutputStream("C://test.txt"); FilterOutputStream fos = new FilterOutputStream(os); fos.write(65);/* w w w.ja v a2s.c o m*/ // forces byte contents to written out to the stream fos.flush(); // create output streams FileInputStream fis = new FileInputStream("C://test.txt"); // read byte int i = fis.read(); // convert integer to characters char c = (char) i; System.out.print("Character read: " + c); fos.close(); fis.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { OutputStream os = new FileOutputStream("C://test.txt"); FilterOutputStream fos = new FilterOutputStream(os); // writes buffer to the output stream fos.write(65);/*from w w w .j a va2 s . co m*/ // forces byte contents to written out to the stream fos.flush(); // create input streams FileInputStream fis = new FileInputStream("C://test.txt"); // get byte from the file int i = fis.read(); // convert integer to character char c = (char) i; System.out.print("Character read: " + c); fos.close(); fis.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { byte[] buffer = { 65, 66, 67, 68, 69 }; int i = 0;//from w w w. ja v a 2 s. c o m OutputStream os = new FileOutputStream("C://test.txt"); FilterOutputStream fos = new FilterOutputStream(os); // writes buffer to the output stream fos.write(buffer, 2, 3); // forces byte contents to written out to the stream fos.flush(); // create input streams FileInputStream fis = new FileInputStream("C://test.txt"); while ((i = fis.read()) != -1) { // converts integer to the character char c = (char) i; System.out.println("Character read: " + c); } fos.close(); fis.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { byte[] buffer = { 65, 66, 67, 68, 69 }; int i = 0;/*from w ww. j a v a 2 s .c om*/ OutputStream os = new FileOutputStream("C://test.txt"); FilterOutputStream fos = new FilterOutputStream(os); // writes buffer to the output stream fos.write(buffer); // forces byte contents to written out to the stream fos.flush(); // create input streams FileInputStream fis = new FileInputStream("C://test.txt"); while ((i = fis.read()) != -1) { // converts integer to the character char c = (char) i; System.out.println("Character read: " + c); } fos.close(); fis.close(); }
From source file:org.wings.UploadFilterManager.java
public static FilterOutputStream createFilterInstance(String name, OutputStream out) { FilterOutputStream filter = null; try {/* ww w . j a v a2 s . c om*/ Entry entry = getFilterEntry(name); if (entry == null) filter = new FilterOutputStream(out); else { Class filterClass = entry.filterClass; if (filterClass != null) { log.info("using " + filterClass.getName() + " for " + name); Constructor constructor = filterClass.getConstructor(new Class[] { OutputStream.class }); filter = (FilterOutputStream) constructor.newInstance(new Object[] { out }); entry.filterInstance = filter; } } } catch (Exception e) { log.fatal("Exception", e); } return filter; }
From source file:com.vmware.photon.controller.model.adapters.vsphere.ovf.CountingEntityWrapper.java
@Override public void writeTo(OutputStream out) throws IOException { super.writeTo(new FilterOutputStream(out) { @Override/* w ww . ja va 2s .c o m*/ public void write(int b) throws IOException { this.out.write(b); CountingEntityWrapper.this.updater.advance(1); } @Override public void write(byte[] b) throws IOException { this.out.write(b); CountingEntityWrapper.this.updater.advance(b.length); } @Override public void write(byte[] b, int off, int len) throws IOException { this.out.write(b, off, len); CountingEntityWrapper.this.updater.advance(len - off); } }); }
From source file:org.jsonschema2pojo.ScalaFileCodeWriter.java
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { final ByteArrayOutputStream javaSourceStream = new ByteArrayOutputStream(); final String javaFileName = getFile(pkg, fileName).getAbsolutePath(); final String scalaFileName = javaFileName.replaceAll("\\.java$", ".scala"); return new FilterOutputStream(javaSourceStream) { public void close() throws IOException { super.close(); final String javaSource = new String(javaSourceStream.toByteArray(), encoding); final String scalaSource = Converter.instance210().convert(javaSource, new ConversionSettings(false)); FileUtils.writeStringToFile(new File(scalaFileName), scalaSource, encoding); }/* w w w. j a v a 2 s. c o m*/ }; }
From source file:org.apache.xml.security.stax.impl.transformer.TransformBase64Decode.java
@Override public void setOutputStream(OutputStream outputStream) throws XMLSecurityException { super.setOutputStream(new Base64OutputStream(new FilterOutputStream(outputStream) { @Override/* ww w . j a va 2 s.c om*/ public void close() throws IOException { //do not close the parent output stream! super.flush(); } }, false)); }
From source file:org.sample.interceptor.MyServerWriterInterceptor.java
@Override public void aroundWriteTo(WriterInterceptorContext wic) throws IOException, WebApplicationException { System.out.println("MyServerWriterInterceptor"); wic.setOutputStream(new FilterOutputStream(wic.getOutputStream()) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); @Override//from w w w.j ava 2 s .c om public void write(int b) throws IOException { baos.write(b); super.write(b); } @Override public void close() throws IOException { System.out.println("MyServerWriterInterceptor --> " + baos.toString()); super.close(); } }); wic.proceed(); }