2362N/A * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @bug 4434723 4482726 4559072 4638365 4795550 5081340 5103988 6253145 0N/A * @summary Test FileChannel.transferFrom and transferTo 0N/A 0,
10,
1023,
1024,
1025,
2047,
2048,
2049 };
0N/A for (
int i=
0; i<
5000; i++)
0N/A // get filechannel for the source file. 0N/A // write out data to the file channel // get filechannel for the dst file. byte[]
srcData =
new byte[] {
1,
2,
3,
4} ;
// get filechannel for the source file. // write out data to the file channel // get filechannel for the dst file. // Test transferTo with large file // Windows and Linux can't handle the really large file sizes for a // truncate or a positional write required by the test for 4563125 // Test transferFrom with large file // Create a source file & large sink file for the test // Create the sink file as a sparse file if possible // re-create as a sparse file // Can't set up the test, abort it // Get new channels for the source and sink and attempt transfer while ((c = r.
read()) != -
1)
// Test transferFrom asking for more bytes than remain in source // Test transferTo to non-blocking socket channel // The sink is a non-blocking socket channel // keep sending until congested // Test transferTo with file positions larger than 2 and 4GB // Creating a sparse 6GB file on Windows takes too long final long G =
1024L *
1024L *
1024L;
// Setup looback connection and echo server // Test data is array of positions and counts {
2*G-
1,
10 },
// across 2GB boundary {
4*G-
1,
10 },
// across 4GB boundary for (
long j=
0; j<
count; j++) {
// write to file and transfer to echo server // check reply from echo server // Test that transferFrom with FileChannel source that is not readable // throws NonReadableChannelException * Creates file blah of specified size in bytes. for(
int i=
0; i<
size; i++) {
* Simple in-process server to echo bytes read by a given socket channel