Examlex
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 .
Q5: Which of the following is an example
Q12: _ is an abstract class that contains
Q15: Describe the difference between an ActionEvent and
Q24: <img src="https://d2lvgg3v3hfg70.cloudfront.net/TBX9005/.jpg" alt=" The above figure
Q24: What is the name of the basic
Q29: If you attempt to instantiate an object
Q34: If you do not provide values for
Q35: The ActionListener interface contains the _ method
Q37: When you use BorderLayout , you are
Q66: When using an array with all elements