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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /* @test
25 * @bug 6448457
26 * @summary Test Channels.newOutputStream returns OutputStream that handles
27 * short writes from the underlying channel
28 */
29
30 import java.io.OutputStream;
31 import java.io.IOException;
32 import java.nio.ByteBuffer;
33 import java.nio.channels.*;
34 import java.util.Random;
35
36 public class ShortWrite {
37
38 static Random rand = new Random();
39 static int bytesWritten = 0;
40
41 public static void main(String[] args) throws IOException {
42
43 WritableByteChannel wbc = new WritableByteChannel() {
44 public int write(ByteBuffer src) {
45 int rem = src.remaining();
46 if (rem > 0) {
47 // short write
|
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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /* @test
25 * @bug 6448457
26 * @summary Test Channels.newOutputStream returns OutputStream that handles
27 * short writes from the underlying channel
28 * @key randomness
29 */
30
31 import java.io.OutputStream;
32 import java.io.IOException;
33 import java.nio.ByteBuffer;
34 import java.nio.channels.*;
35 import java.util.Random;
36
37 public class ShortWrite {
38
39 static Random rand = new Random();
40 static int bytesWritten = 0;
41
42 public static void main(String[] args) throws IOException {
43
44 WritableByteChannel wbc = new WritableByteChannel() {
45 public int write(ByteBuffer src) {
46 int rem = src.remaining();
47 if (rem > 0) {
48 // short write
|