8189775: java/nio/channels/FileChannel/directio/ReadDirect.java failed with NumberFormatException

Clamp the offset so the scattering read remains within the channel.

Reviewed-by: rriggs
diff --git a/test/jdk/java/nio/channels/FileChannel/directio/ReadDirect.java b/test/jdk/java/nio/channels/FileChannel/directio/ReadDirect.java
index c8d6af4..6d57f0a 100644
--- a/test/jdk/java/nio/channels/FileChannel/directio/ReadDirect.java
+++ b/test/jdk/java/nio/channels/FileChannel/directio/ReadDirect.java
@@ -177,7 +177,12 @@
                 }
             }
 
-            randomNumber = generator.nextInt(100);
+            // The size of the test FileChannel is 100*charsPerGroup.
+            // As the channel bytes will be scattered into two buffers
+            // each of size charsPerGroup, the offset cannot be greater
+            // than 98*charsPerGroup, so the value of randomNumber must
+            // be in the range [0,98], i.e., 0 <= randomNumber < 99.
+            randomNumber = generator.nextInt(99);
             long offset =  randomNumber * charsPerGroup;
             fc.position(offset);
             fc.read(dests, 1, 2);