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

  Finding counterexample-algorithm based on greedy strategy

Determine a counterexample for following algorithm based on greedy strategy.

  Design circuit buffer last-in first-out lifo

I want design circuit this Buffer(LIFO). This blocking is for FIFO memory but i want design circuit Buffer Last-in First-out LIFO 4*4

  Finding project schedule if critical path is identified

Describe in scholarly detail how you find out a project schedule once critical path has been identified.

  Explain bindings which are required to determine semantics

Write simple assignment statement with one arithmetic operator in some language you know. For each component of statement, write various bindings which are needed to determine semantics.

  Computing cycles to save if registers are available

Determine the number of cycles will be saved if both registers are available?

  Social networking website to get information about applicant

Some companies are beginning to use social networking websites like Facebook and MySpace, to get information about job applicants.

  Limitations of the use of ai technologies

Determine some of the limitations or dangers you see in the use of AI technologies such as expert systems, virtual reality, and intelligent agents?

  Function that uses a switch statement

To locate nearest numbered cross street for a given avenue address, the following algorithm can be used: cancel last diget of the address, divide by two,

  Store configuration information on motherboard in cmos

Why do you believe the trend is to store configuration information on the motherboard in CMOS setup rather than by using jumpers or switches?

  State turing machine m that calculates function

State a Turing Machine M that computes the function f: {a, b}* → N, where: f(x) = the unary encoding of max(#a(x), #b(x)).

  Data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs, Flash RAM, and solid-state drives

  Determine number of toes of chicken using calculations

If radix r utilized by chicken corresponds to its total number of toes, determine how many toes does chicken have on each foot?

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