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

  Write program to make change for cost of item

Write down a C# program to make change. Enter cost of item which is less than one dollar. Output coins given as change, by using quarters, dimes, nickels, and pennies.

  Comparing accuracies using test options

Compare the accuracies obtained using the three "test options": "Use training set", "cross-validation" and "percentage split".

  Internet changes consumer and supplier relationships

Considering a focus in area of E-Commerce (EC), how would you think Internet changes consumer and supplier relationships?

  Explain the roles of computer forensics expert

Explain the roles of computer forensics expert and computer security expert. You should include the following: Which specific positions (job titles) are in demand within business organizations?

  Flight availability request application

Define a simple Web Service in WSDL that returns flight information regarding flights of a particular flight operator, see the first question

  Create user-s requirements specification for easydrive

Create a user's requirements specification for the EasyDrive School of Motoring database system. Use a single major user view for the application (Director View).

  Relationship between certifications and performance

Describe the relationship between certifications and performance? What does "performance" mean and how do you measure it?

  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.

  Main attributes of product in plug-ins change process

What are some main attributes of product and how may it help operations of organization? How do third-party plug-ins change process of diagnosing and troubleshooting errors in application?

  Explaining health insurance portability-accountability act

Based on your knowledge of IT security management, argue for or against assertions that Epworth system is in compliance with Health Insurance Portability and Accountability Act (HIPAA).

  Effective-protecting intellectual property in digital media

Which is more likely to be effective in protecting intellectual property in digital media such as CDs and DVDs: tougher copyright laws or new technologies incorporating.

  Explain hardware implementations of intelligent agents

There are hardware implementations of intelligent agents. Determine the literature instances of intelligent agents as software. Compare and contrast two implementations.

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