Comma-delimited text file

Assignment Help Basic Computer Science
Reference no: EM13158771

Write an application that allows you to enter any ID number and displays the first and last name for the record stored in the employee file with the given ID number. Display an appropriate message if the ID number cannot be found in the input file.

This is based on a comma-delimited text file that has already been created containing a 3 digit ID # and a first and last name. The last part of the excercise is as follows:

Write an application that allows you to enter any first name and displays all the
ID numbers and last names for any records stored in the employee file with the
given first name. Display an appropriate message if the first name cannot be
found in the input file.

Here's what I've got so far. It only displays the ID# and 000, , :

import java.nio.file.*;
import java.nio.channels.FileChannel;
import java.nio.ByteBuffer;
import static java.nio.file.StandardOpenOption.*;
import java.util.Scanner;

public class DisplaySelectedIdNumbers {

public static void main(String[] args) {

Scanner keyBoard = new Scanner(System.in);
Path file
= Paths.get("C:\\Users\\Jeremiah\\Documents\\Test\\writeFile.txt");
String s = "000,   , "
+ System.getProperty("line.separator");
final int RECSIZE = s.length();
byte[] data = s.getBytes();
ByteBuffer buffer = ByteBuffer.wrap(data);
FileChannel fc = null;
String idString;
int id;

try {
fc = (FileChannel) Files.newByteChannel(file, READ, WRITE);
System.out.print("Enter employee ID number ");
idString = keyBoard.nextLine();
id = Integer.parseInt(idString);
buffer = ByteBuffer.wrap(data);
fc.position(id * RECSIZE);
fc.read(buffer);
s = new String(data);
System.out.println("ID #" + id + " " + s);
fc.close();
} catch (Exception e) {
System.out.println("Error message: " + e);
}
}
}

Reference no: EM13158771

Questions Cloud

Problem related to short-term notes payable : On December 31, 2010, Irey Co. has $2,000,000 of short-term notes payable due on February 14, 2011. On January 10, 2011, Irey arranged a line of credit with County Bank which allows Irey to borrow up to $1,500,000 at one percent above the prime ra..
How many of the offspring would you expect to show : Genes A/a and B/b are linked and known to be 20 map units apart. Individuals heterozygous for both of these genes (genotypes= AB/ab) were mated with each other. If there 2000 offspring from this cross, how many of the offspring would you expect to..
Explain the design of a public policy that would subsidize : Explain the design of a public policy that would subsidize the private performance of the R&D (to ensure that the research is done by the private sector) yet would minimize the public funds used.
Struggle of the orders in early rome : Discuss the class struggle between the Patricians and the Plebeians and the resulting Struggle of the Orders in early Rome. What rights did the Plebeians gain through this struggle?
Comma-delimited text file : This is based on a comma-delimited text file that has already been created containing a 3 digit ID # and a first and last name. The last part of the excercise is as follows.
What kind of sons or daughters can they have : An albino, non-hemophiliac man married a normally-pigmented, non-hemopheliac women; her father was a hemophiliac and her mother was an albino. What kind of sons/daughters can they have and in what proportion?
How do public goods and private goods compare : how do public goods and private goods compare? open a supply and demand curve. in whcih direction do the shift if they both decease?
Segments of the hospitality and tourism industries : Identify and describe the segments of the hospitality and tourism industries. Use examples to support your response
Describe what concentration in ppm would it constitute : If all 0.44 gigatons CO2 remain in the atmosphere and spread around the atmosphere evenly, what concentration in ppm would it constitute?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd