Short Answer
import java.nio.file.*;
import java.io.*;
import java.nio.channels.FileChannel;
import java.nio.ByteBuffer;
import static java.nio.file.StandardOpenOption.*;
public class CreateOneRandomAccessRecord
{
public static void main(String[] args)
{
Path file =
Paths.get("C:\\Java\\Chapter.13\\RandomEmployees.txt");
String s = "002,Newmann,12.25" +
System.getProperty("line.separator");
--------- Code here -------------
byte[] data = s.getBytes();
ByteBuffer buffer = ByteBuffer.wrap(data);
FileChannel fc = null;
try
{
fc = (FileChannel)Files.newByteChannel(file, READ, WRITE);
fc.position(2 * RECSIZE);
fc.write(buffer);
fc.close();
}
catch (Exception e)
{
System.out.println("Error message: " + e);
}
}
}
The above program creates a single employee record for employee number 002 with a last name of Newmann and a pay rate of 12.25. In the indicated space, create a statement that assigns the length of the string to RECSIZE .
Correct Answer:

Verified
final int ...View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Correct Answer:
Verified
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q24: Explain the difference between an absolute path
Q41: A(n) _ field is the field in
Q44: A data file can be used as
Q48: _ applications require that a record be
Q53: When you use the BufferedReader class, you
Q55: A file channel is _, meaning you
Q59: The String class _ method accepts an
Q64: You can direct System.err to a new
Q66: Match each term with the correct statement
Q71: Provide an example of batch processing.