Examlex
import java.nio.file.*;
import java.io.*;
import java.nio.channels.FileChannel;
import java.nio.ByteBuffer;
import static java.nio.file.StandardOpenOption.*;
import java.util.Scanner;
public class CreateEmployeesRandomFile
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
Path file =
Paths.get("C: \\Java\\Chapter.13\\RandomEmployees.txt");
String s = "000, ,00.00" +
System.getProperty("line.separator");
final int RECSIZE = s.length();
FileChannel fc = null;
String delimiter = ",";
String idString;
int id;
String name;
String payRate;
final String QUIT = "999";
try
{
fc = (FileChannel)Files.newByteChannel(file, READ, WRITE);
System.out.print("Enter employee ID number >> ");
idString = input.nextLine();
while(!(idString.equals(QUIT)))
{
_____________________________
System.out.print("Enter name for employee #" +
id + " >> ");
name = input.nextLine();
System.out.print("Enter pay rate >> ");
payRate = input.nextLine();
s = idString + delimiter + name + delimiter +
payRate + System.getProperty("line.separator");
byte[] data = s.getBytes();
ByteBuffer buffer = ByteBuffer.wrap(data);
_____________________________
fc.write(buffer);
System.out.print("Enter next ID number or " +
QUIT + " to quit >> ");
idString = input.nextLine();
}
fc.close();
}
catch (Exception e)
{
System.out.println("Error message: " + e);
}
The above program will accept any number of employee records as user input and write the records to a file in a loop. In the first shaded line, create the statement to accept the employee data value from the keyboard as a String and convert it to an integer using the parseInt() method. In the second shaded line, create the statement to compute the record's desired position by multiplying the ID number value by the record size.
Evolutionary Relationships
The connections among species or groups of organisms that show how they are related through evolution, often depicted in a phylogenetic tree.
Organisms
Living entities that can function independently, ranging from microscopic bacteria to complex animals and plants.
Aristotle
An ancient Greek philosopher and polymath, whose writings covered diverse fields such as metaphysics, biology, ethics, and politics, significantly influencing Western intellectual history.
Phylogeny
The complete evolutionary history of a group of organisms.
Q1: Object-oriented techniques to manage errors<br>A)Throwable<br>B)Exception(String message)<br>C)exception handling<br>D)syntactic
Q2: When using an array with all elements
Q19: Describe how a programmer would use the
Q19: What are the four JFrame constructors?
Q22: The following statement produces a dark purple
Q27: You can store data in variables within
Q30: What are some of the advantages of
Q50: Numbered beginning with 0<br>A)array variable<br>B)reference type<br>C)elements<br>D)int<br>E)Java object
Q53: If you call getGraphics() in a frame
Q74: A(n) _ object is an avenue for