本文整理匯總了Java中java.io.FilterWriter類的典型用法代碼示例。如果您正苦於以下問題:Java FilterWriter類的具體用法?Java FilterWriter怎麽用?Java FilterWriter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FilterWriter類屬於java.io包,在下文中一共展示了FilterWriter類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getWriter
import java.io.FilterWriter; //導入依賴的package包/類
public Writer getWriter()
{
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
return new FilterWriter(new OutputStreamWriter(bytesOut, UTF8))
{
@Override
public void flush() throws IOException
{
super.flush();
publishData();
}
@Override
public void close() throws IOException
{
super.close();
publishData();
}
private void publishData()
{
XmlResult.this.dataHolder = new BytesDataHolder(bytesOut.toByteArray());
}
};
}
示例2: openWriter
import java.io.FilterWriter; //導入依賴的package包/類
@Override
public Writer openWriter() {
return new FilterWriter(new StringWriter()) {
@Override
public void close() throws IOException {
out.close();
String text = ((StringWriter) out).toString();
save(location, name, new Content() {
@Override
public byte[] getBytes() {
return text.getBytes();
}
@Override
public String getString() {
return text;
}
});
}
};
}
示例3: FilterWriter
import java.io.FilterWriter; //導入依賴的package包/類
/**
* @tests java.io.FilterWriter#FilterReader(java.io.Reader)
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "Verifies constructor FilterWriter(java.io.Writer).",
method = "FilterWriter",
args = {java.io.Writer.class}
)
public void test_ConstructorLjava_io_Writer() {
FilterWriter myWriter = null;
called = true;
try {
myWriter = new MyFilterWriter(null);
fail("NullPointerException expected.");
} catch (NullPointerException e) {
// expected
}
}
示例4: createWriter
import java.io.FilterWriter; //導入依賴的package包/類
@Override
public HierarchicalStreamWriter createWriter(final Writer out) {
final HierarchicalStreamWriter[] writer = new HierarchicalStreamWriter[1];
final FilterWriter filter = new FilterWriter(out) {
@Override
public void close() {
writer[0].close();
}
};
writer[0] = new Dom4JXmlWriter(new XMLWriter(filter, outputFormat), getNameCoder());
return writer[0];
}
示例5: test_ConstructorLjava_io_Writer
import java.io.FilterWriter; //導入依賴的package包/類
public void test_ConstructorLjava_io_Writer() {
FilterWriter myWriter = null;
called = true;
try {
myWriter = new MyFilterWriter(null);
fail("NullPointerException expected.");
} catch (NullPointerException e) {
// expected
}
}
示例6: createWriter
import java.io.FilterWriter; //導入依賴的package包/類
public HierarchicalStreamWriter createWriter(Writer paramWriter)
{
final HierarchicalStreamWriter[] arrayOfHierarchicalStreamWriter = new HierarchicalStreamWriter[1];
arrayOfHierarchicalStreamWriter[0] = new Dom4JXmlWriter(new XMLWriter(new FilterWriter(paramWriter)
{
public void close()
{
arrayOfHierarchicalStreamWriter[0].close();
}
}
, this.outputFormat), getNameCoder());
return arrayOfHierarchicalStreamWriter[0];
}
示例7: create
import java.io.FilterWriter; //導入依賴的package包/類
@Override public Writer create(Writer delegate) throws Exception {
return new FilterWriter(delegate) {};
}