blob: 2bbab79b92373e54a41d661fabfd8c4fe2c235d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Helper for
// Copyright (c) 2001 Free Software Foundation
// This file is part of Mauve.
// Tags: not-a-test
package gnu.testlet.java.io.BufferedOutputStream;
import java.io.*;
public class helper extends OutputStream
{
// Number of bytes we've read.
int count;
// When we should stop.
int stop;
public helper (int size)
{
stop = size;
}
private void update (int howmuch) throws InterruptedIOException
{
if (count + howmuch > stop)
{
InterruptedIOException ioe = new InterruptedIOException ();
ioe.bytesTransferred = stop - count;
count = stop;
throw ioe;
}
count += howmuch;
}
public void write (int b) throws InterruptedIOException
{
update (1);
}
public void write (byte[] b, int off, int len) throws InterruptedIOException
{
if (off < 0 || len < 0 || off + len > b.length)
throw new ArrayIndexOutOfBoundsException ();
update (len);
}
}
|