hey guys,
i'm new to java ,,,and i have a problem wish u to get ur answer ASAP
i'm reading from a text file by PrintWriter , and there are 3 rows first row is ID
second row is name and third row is address. and i want to get the IDs into the java program so
that i could call a name with it.for example : if in the text file 001 is linked to "name" i want to call
that name by calling the id in the program....thanks.

Recommended Answers

All 3 Replies

and what exactly are you having trouble with? can you show us the code you've got so far and tell us where it's going wrong?

i explained everything in the text file....if it's possible please take a look and give me a proper solution :)

thank you very much ...

I don't really see you entering or using the input, so what exactly are you trying to do?

for instance:

String lineToRemove = remove;

where do you instantiate the 'remove' variable? it's pretty hard to see in that .txt. can't you paste your code in a post here, in a seperate code block per class?

or, for this:

if(trimmedLine.equals(lineToRemove)) continue;

now, as I said, I'm not entirely sure, but, you only read the number, say 002.
have you tried:

if(trimmedLine.startsWith(lineToRemove)) continue;

personally, I would recommend against using the continue; keyword.

replace it with something like this:

if(!(trimmedLine.equals(lineToRemove)))
    writer.write(currentLine);

or, if I'm right with my guess that lineToRemove doesn't contain the value you need:

if(!(trimmedLine.startsWith(lineToRemove)))
    writer.write(currentLine);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.