Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

how to read a specific line of a .dat file?

843785Dec 14 2008 — edited Dec 15 2008
can we read a specific line of a .dat file, if so, how?
i have this .dat files for each customer, which contain their name on the first line, their id on the second line
and a list of items and an item id between each item.

John Doe
455689
milk
1
orange
9

Here is what I am trying to do, please correct me

...
//list out .dat file in dir
File customer_dir = new File ("Customer")
if (customer_dir.isDirectory())
{
String[] listofdat=dir.list();
}

for (int i=0;i<listofdat.length();i++)
{
Scanner dat_read = new Scanner (new File listfodat);
dat_read.nextLine();
if (dat_read.nextLine().equals("455689")) <--is this okay?
{

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 12 2009
Added on Dec 14 2008
6 comments
482 views