• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FilterOutputStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中java.io.FilterOutputStream的典型用法代码示例。如果您正苦于以下问题:Java FilterOutputStream类的具体用法?Java FilterOutputStream怎么用?Java FilterOutputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FilterOutputStream类属于java.io包,在下文中一共展示了FilterOutputStream类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: openBinary

import java.io.FilterOutputStream; //导入依赖的package包/类
@Override
public OutputStream openBinary(final JPackage pkg, String fileName) throws IOException {
    final ByteArrayOutputStream javaSourceStream = new ByteArrayOutputStream();

    final String scalaFileName = fileName.replaceAll("\\.java$", ".scala");

    return new FilterOutputStream(javaSourceStream) {
        @Override
        public void close() throws IOException {
            super.close();

            final String javaSource = new String(javaSourceStream.toByteArray(), "utf-8");
            final String scalaSource = Converter.instance210().convert(javaSource, new ConversionSettings(false));

            OutputStream parentStream = ScalaZipCodeWriter.super.openBinary(pkg, scalaFileName);
            parentStream.write(scalaSource.getBytes("utf-8"));
        }
    };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:ScalaZipCodeWriter.java


示例2: openBinary

import java.io.FilterOutputStream; //导入依赖的package包/类
@Override
public OutputStream openBinary(final JPackage pkg, String fileName) throws IOException {
    final ByteArrayOutputStream javaSourceStream = new ByteArrayOutputStream();

    final String scalaFileName = fileName.replaceAll("\\.java$", ".scala");

    return new FilterOutputStream(javaSourceStream) {
        @Override
        public void close() throws IOException {
            super.close();

            final String javaSource = new String(javaSourceStream.toByteArray(), "utf-8");
            final String scalaSource = Converter.instance210().convert(javaSource, new ConversionSettings(false));

            OutputStream parentStream = ScalaSingleStreamCodeWriter.super.openBinary(pkg, scalaFileName);
            parentStream.write(scalaSource.getBytes("utf-8"));
        }
    };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:ScalaSingleStreamCodeWriter.java


示例3: openBinary

import java.io.FilterOutputStream; //导入依赖的package包/类
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);
        }
    };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:ScalaFileCodeWriter.java


示例4: outputStream

import java.io.FilterOutputStream; //导入依赖的package包/类
private OutputStream outputStream() throws IOException {
    FileObject fo = toPropertiesFile(true);
    final FileLock lock = fo.lock();
    OutputStream os = null;
    try {
        os = fo.getOutputStream(lock);
    } finally {
        if(os == null && lock != null) {
            // release lock if getOutputStream failed
            lock.releaseLock();
        }
    }
    return new FilterOutputStream(os) {
        public @Override void close() throws IOException {
            super.close();
            lock.releaseLock();
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:PropertiesStorage.java


示例5: getOutputStreamForMac42624

import java.io.FilterOutputStream; //导入依赖的package包/类
private OutputStream getOutputStreamForMac42624(final OutputStream originalStream, final String name) {
    final File f = getFile(name);
    final long lModified = f.lastModified();
    OutputStream retVal = new FilterOutputStream(originalStream) {

        @Override
        public void close() throws IOException {
            super.close();

            if ((f.length() == 0) && (f.lastModified() == lModified)) {
                f.setLastModified(System.currentTimeMillis());
            }
        }
    };

    return retVal;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:LocalFileSystem.java


示例6: TestFileSystem

import java.io.FilterOutputStream; //导入依赖的package包/类
TestFileSystem(LocalFileSystem lfs, String testName) throws Exception {
    super();
    if ("testOutputStreamFiresIOException".equals(testName)) {
        this.info = new LocalFileSystem.Impl(this) {
            public OutputStream outputStream(String name) throws java.io.IOException {
                throw new IOException();
            }
        };
    } else if ("testCloseStreamFiresIOException".equals(testName)) {
        this.info = new LocalFileSystem.Impl(this) {
            public OutputStream outputStream(String name) throws java.io.IOException {
                return new FilterOutputStream(super.outputStream(name)) {
                    public void close() throws IOException {
                        throw new IOException();
                    }
                };
            }
        };
    }
    setRootDirectory(lfs.getRootDirectory());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:FileObject75826Test.java


示例7: getOutputStream

import java.io.FilterOutputStream; //导入依赖的package包/类
public OutputStream getOutputStream()
{
	return new FilterOutputStream(new ByteArrayOutputStream())
	{
		@Override
		public void flush() throws IOException
		{
			super.flush();
			publishData();
		}

		@Override
		public void close() throws IOException
		{
			super.close();
			publishData();
		}

		private void publishData()
		{
			ByteArrayOutputStream bytesOut = (ByteArrayOutputStream) out;
			XmlResult.this.dataHolder = new BytesDataHolder(bytesOut.toByteArray());
		}
	};
}
 
开发者ID:fluentxml4j,项目名称:fluentxml4j,代码行数:26,代码来源:XmlResult.java


示例8: CacheRequestImpl

import java.io.FilterOutputStream; //导入依赖的package包/类
public CacheRequestImpl(final DiskLruCache.Editor editor) throws IOException {
  this.editor = editor;
  this.cacheOut = editor.newOutputStream(ENTRY_BODY);
  this.body = new FilterOutputStream(cacheOut) {
    @Override public void close() throws IOException {
      synchronized (HttpResponseCache.this) {
        if (done) {
          return;
        }
        done = true;
        writeSuccessCount++;
      }
      super.close();
      editor.commit();
    }

    @Override public void write(byte[] buffer, int offset, int length) throws IOException {
      // Since we don't override "write(int oneByte)", we can write directly to "out"
      // and avoid the inefficient implementation from the FilterOutputStream.
      out.write(buffer, offset, length);
    }
  };
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:24,代码来源:HttpResponseCache.java


示例9: openOutputStream

import java.io.FilterOutputStream; //导入依赖的package包/类
@Override
public OutputStream openOutputStream() {
    return new FilterOutputStream(new ByteArrayOutputStream()) {
        @Override
        public void close() throws IOException {
            out.close();
            byte[] bytes = ((ByteArrayOutputStream) out).toByteArray();
            save(location, name, new Content() {
                @Override
                public byte[] getBytes() {
                    return bytes;
                }
                @Override
                public String getString() {
                    return new String(bytes);
                }

            });
        }
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:ToolBox.java


示例10: openBinary

import java.io.FilterOutputStream; //导入依赖的package包/类
@Override
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
    final String name = pkg != null && pkg.name().length() > 0
            ? pkg.name() + '.' + fileName : fileName;

    out.println(
        "-----------------------------------" + name +
        "-----------------------------------");

    return new FilterOutputStream(out) {
        @Override
        public void close() {
            // don't let this stream close
        }
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:SingleStreamCodeWriter.java


示例11: eConnect

import java.io.FilterOutputStream; //导入依赖的package包/类
@Override public synchronized void eConnect(Socket socket, int clientId) throws IOException {
	super.eConnect(socket, clientId);

	// replace the output stream with one that logs all data to m_outLogger
	if (isConnected()) {
		try {
			Field realOsField = FilterOutputStream.class.getDeclaredField( "out");
			realOsField.setAccessible( true);
			OutputStream realOs = (OutputStream)realOsField.get( m_dos);
			realOsField.set( m_dos, new MyOS( realOs) );
		}
		catch( Exception e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:rterp,项目名称:SumZeroTrading,代码行数:17,代码来源:ApiConnection.java


示例12: test_flush

import java.io.FilterOutputStream; //导入依赖的package包/类
public void test_flush() throws IOException {
    Support_OutputStream sos = new Support_OutputStream(550);
    os = new FilterOutputStream(sos);
    os.write(fileString.getBytes(), 0, 500);
    os.flush();
    assertEquals("Test 1: Bytes not written after flush;",
            500, sos.size());

    sos.setThrowsException(true);
    try {
        os.flush();
        fail("Test 2: IOException expected.");
    } catch (IOException e) {
        // Expected.
    }
    sos.setThrowsException(false);
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:18,代码来源:OldFilterOutputStreamTest.java


示例13: Support_OutputStream

import java.io.FilterOutputStream; //导入依赖的package包/类
public void test_write$B() throws IOException {
    Support_OutputStream sos = new Support_OutputStream(testLength);
    os = new FilterOutputStream(sos);
    os.write(fileString.getBytes());

    bis = new ByteArrayInputStream(sos.toByteArray());
    assertTrue("Test 1: Bytes have not been written.",
            bis.available() == testLength);
    byte[] wbytes = new byte[testLength];
    bis.read(wbytes, 0, testLength);
    assertTrue("Test 2: Incorrect bytes written or read.",
            fileString.equals(new String(wbytes)));

    try {
        // Support_OutputStream throws an IOException if the internal
        // buffer is full, which it should be now.
        os.write(42);
        fail("Test 2: IOException expected.");
    } catch (IOException e) {
        // Expected.
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:23,代码来源:OldFilterOutputStreamTest.java


示例14: test_writeI

import java.io.FilterOutputStream; //导入依赖的package包/类
public void test_writeI() throws IOException {
    Support_OutputStream sos = new Support_OutputStream(1);
    os = new FilterOutputStream(sos);
    os.write(42);

    bis = new ByteArrayInputStream(sos.toByteArray());
    assertTrue("Test 1: Byte has not been written.",
            bis.available() == 1);
    assertEquals("Test 2: Incorrect byte written or read;",
            42, bis.read());

    try {
        // Support_OutputStream throws an IOException if the internal
        // buffer is full, which it should be now.
        os.write(42);
        fail("Test 2: IOException expected.");
    } catch (IOException e) {
        // Expected.
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:21,代码来源:OldFilterOutputStreamTest.java


示例15: writeWithBackup

import java.io.FilterOutputStream; //导入依赖的package包/类
private OutputStream writeWithBackup() throws IOException {

        // 1. delete filename.new if it exists
        delete(".new");

        // 2. if filename exists, rename it to filename.backup (deleting old backup)
        if (lastModified("") != null) {
            delete(".backup");
            rename("", ".backup");
        }

        // 3. create filename.new, returning a stream for writing its content
        return new FilterOutputStream(write(".new")) {

            @Override
            public void close() throws IOException {
                super.close();
                rename(".new", "");
            }

        };
    }
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:23,代码来源:Dictionary.java


示例16: setEncoding

import java.io.FilterOutputStream; //导入依赖的package包/类
/**
 * Change the encoding used by this connection.
 *
 * @param encoding the new encoding to use
 * @throws IOException if something goes wrong
 */
public void setEncoding(Encoding encoding) throws IOException {
    // Close down any old writer.
    if (encodingWriter != null)
        encodingWriter.close();

    this.encoding = encoding;

    // Intercept flush() downcalls from the writer; our caller
    // will call PGStream.flush() as needed.
    OutputStream interceptor = new FilterOutputStream(pg_output) {
                                   public void flush() throws IOException {
                                   }
                                   public void close() throws IOException {
                                       super.flush();
                                   }
                               };

    encodingWriter = encoding.getEncodingWriter(interceptor);
}
 
开发者ID:yngui,项目名称:jephyr,代码行数:26,代码来源:PGStream.java


示例17: createIndexableFields

import java.io.FilterOutputStream; //导入依赖的package包/类
@Override
public Field[] createIndexableFields(Shape shape) {
  int bufSize = Math.max(128, (int) (this.indexLastBufSize * 1.5));//50% headroom over last
  ByteArrayOutputStream byteStream = new ByteArrayOutputStream(bufSize);
  final BytesRef bytesRef = new BytesRef();//receiver of byteStream's bytes
  try {
    ctx.getBinaryCodec().writeShape(new DataOutputStream(byteStream), shape);
    //this is a hack to avoid redundant byte array copying by byteStream.toByteArray()
    byteStream.writeTo(new FilterOutputStream(null/*not used*/) {
      @Override
      public void write(byte[] b, int off, int len) throws IOException {
        bytesRef.bytes = b;
        bytesRef.offset = off;
        bytesRef.length = len;
      }
    });
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  this.indexLastBufSize = bytesRef.length;//cache heuristic
  return new Field[]{new BinaryDocValuesField(getFieldName(), bytesRef)};
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:SerializedDVStrategy.java



注:本文中的java.io.FilterOutputStream类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JsonCreator类代码示例发布时间:2022-05-20
下一篇:
Java XPathFactory类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap