/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/* @test * @bug 5067405 * @summary Basic test for classes which implement Appendable.
*/
privatestaticfinal String s = "Beware the Jabberwock, my son!"; privatestatic CharArrayWriter gw = new CharArrayWriter(); privatestatic ByteArrayOutputStream gos = new ByteArrayOutputStream();
// Appendables/Writers
Object [][] wa = { { new CharArrayWriter(), testCharArrayWriter },
{ new BufferedWriter(gw), testBufferedWriter }, // abstract, no implementing classes in jdk // { new FilterWriter(), testFilterWriter },
{ new FileWriter(gf), testFileWriter },
{ new OutputStreamWriter(gos), testOutputStreamWriter }, // covered by previous two test cases // { new PipedWriter(gw), testPipedWriter },
{ new PrintWriter(gw), testPrintWriter },
{ new StringWriter(), testStringWriter },
};
for (int i = 0; i < ca.length; i++) {
CharSequence a = ca[i]; for (int j = 0; j < wa.length; j++)
test((Writer)wa[j][0], a, (BasicRunnable)wa[j][1]);
// other Appendables
test(new PrintStream(gos), a, testPrintStream);
test(CharBuffer.allocate(128), a, testCharBuffer);
test(ByteBuffer.allocateDirect(128).asCharBuffer(), a, testCharBuffer);
test(new StringBuffer(), a, testStringBuffer);
test(new StringBuilder(), a, testStringBuilder);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.