blob: e7f19ef1227e403fded89c96fcab69dbbec26417 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1997 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24/* @test
25 @summary Test interaction of buffer sizes in buffered char and byte streams
26 */
27
28import java.io.*;
29
30public class BufferSizes {
31
32 static int min = 90;
33 static int max = 110;
34 static int chunk = 100;
35 static int count = 1000;
36
37 static void runBytes() throws IOException {
38 for (int sz = min; sz <= max; sz++) {
39 System.err.println(sz);
40 InputStream in
41 = new BufferedInputStream(new ABCInputStream(count, chunk), sz);
42 OutputStream out
43 = new BufferedOutputStream(new ABCOutputStream(count), sz);
44 int n;
45 byte[] buf = new byte[sz];
46 while ((n = in.read(buf, 0, sz)) != -1)
47 out.write(buf, 0, n);
48 in.close();
49 out.close();
50 }
51 }
52
53
54 static void runChars() throws IOException {
55 for (int sz = min; sz <= max; sz++) {
56 System.err.println(sz);
57 Reader in
58 = new BufferedReader(new InputStreamReader(new ABCInputStream(count, chunk)), sz);
59 Writer out
60 = new BufferedWriter(new OutputStreamWriter(new ABCOutputStream(count)), sz);
61 int n;
62 char[] cbuf = new char[sz];
63
64 while ((n = in.read(cbuf, 0, sz)) != -1)
65 out.write(cbuf, 0, n);
66 in.close();
67 out.close();
68 }
69 }
70
71 public static void main(String[] args) throws IOException {
72 runBytes();
73 runChars();
74 }
75
76}