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

  System designer to make sure implementation went smoothly

In new system implementation, what would you do as lead system designer to make sure implementation went smoothly?

  Evaluate for risk management purposes

Choose three information assets that a typical organization has and evaluate for risk management purposes which vulnerability should be evaluated for additional controls first?

  Create a driver class to instantiates-updates several object

Create a driver class called FlightTest whose main method instantiates and updates several Flight objects. Two classes are required for this project: Flight and FlightTest.

  Explaining major provisions of telecommunications act

Write down some of the major provisions of the Telecommunications Act of 1996?

  Performing swot analysis on viability of upgrading server

Carry out a SWOT analysis on the viability of upgrading to Server 2008.

  Study ai literature to find-task can be solved by computers

Study the AI literature to find whether or not the following tasks can presently be solved by computers. Give proper reference to support your answer.

  How to use system tools to identify problems

How can you use system tools, such as the Task Manager, to help identify and troubleshoot these problems? Report your findings in a one page paper.

  Subsets of integers which sum to the same number

How many numbers do you require from this generator to guarantee that there exist 2 subsets of integers which  sum to the same number? Write steps how derive the solution.

  Determine total hours committed by employee

Assume the weekly hours for all employees are stored in the two-dimensional array. Each row records the employee's seven-day work hours with seven columns. Determine total hours committed by each employee every week.

  Experts suggest regarding search for information on internet

Which of the following do experts recommend regarding the search for information on the Internet? Avoid Boolean operators since new technology has made them obsolete.

  Importance of top management commitment

Discuss the importance of top management commitment and the development of standards for successful project management. Provide examples to illustrate the importance of these items.

  Creating cut-over plan for alternate processing site

Create cut-over plan for alternate processing site based on given below. Consider LAN for small 100-person business, Pixel Inc. Business occupies one floor in an office building.

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