interactive java

Guys i'm back again. I know this might sound a bit daft on my part but forgive i'm still a novice.
I've done the hard part of the question but i'm stuttering on the construction of a class that will enable users to enter towns in the command prompt and all details for that particular town pop up.
I've done the following , and forgive i've changed the codes so many times because i'm constantly getting errors and hence it looks a bit messy, someone fresh needs to have a look.
Just to remind the format for each town is eg NAMMOTH:NM:280520:-10550:440:464
Nammoth being the town, NM(county code),280520 lat,10550 lon, 440km (east coord) and 464km (north coord).
please feel free to ask me further ? , if u don't understand my ?, i can hardly understand it myself.

THANK YOU

import java.io.*;
public class Distances
{
      public static void main(String[] args)
      {
             
      try
       {
        BufferedReader in = new BufferedReader(new FileReader("towns.txt"));
        String str;
        while ((str = in.readLine()) != null) {
            towns.add(new Town(str));

                 
        
            {
            
                  int town_name;      
                  if line = town_name. = (NAMMOTH)               {
                       System.out.println("Town Found");
                }
                         
           }
           catch( IOException e )
           {
            System.err.println("IO Exception");
            System.exit(1);

           }      
        }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
}            

RamsTheDonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RamsTheDonAuthor Commented:
sorry the more structred prg is as:
import java.io.*;
public class cities
 {
      public static void main(String[] args)
        {

          try
          {
            FileReader file=new FileReader("towns.txt");
            BufferedReader buffer=new BufferedReader(file);
      
            int town_name;
            String town = "NAMMOTH:NM:280520:-10550:440:464";      
            if line==town_name.=(NAMMOTH)
              {
            System.out.println("Town Found");
              }
                try
                {
                    while((textline = buffer.readLine()) !=null)
                  System.out.println(textline);
                  buffer.close();

           
                
             }
             catch( IOException e )
             {
                  System.err.println("IO Exception");
                  System.exit(1);
            }
          catch(FileNotFoundException fnex)
          {
            System.out.println("Couldn't find file");
            System.out.println(":" + fnex.getMessage());
            System.exit(1);
                }      
       }
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
            
brettmjohnsonCommented:
>          if line==town_name.=(NAMMOTH)

That does not even approximate legal Java syntax.
What is it that you are actually trying to test?
(Just use english words to describe the condition.)


You should also consider using a programmer's text editor that
automatically indents the code and balances braces, brackets, and
parenthesis.  That would certainly help with the readability of your
code.  An editor with syntax coloring would also help you identify
grossly incorrect syntax (such as your if statement).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
_iskywalker_Commented:
and what is line?
is it the read line?
You didnt also define what is the textline. You should parse one line at time since, it is
the smallest complete piece of information that you have:
String  textline =NULL;
while((textline = buffer.readLine()) !=null){
               System.out.println(textline);
               ParsedInformations muh=parseInformation(textfile);
if(compareInformation(muh, searchingTown)){
printInformation(muh);
}
}
This isnt good indented, but you see creating objects for you strings maybe is a better way of structuring your code. Creating functions working on that objects would be the next step for making a good fileparser. There are still some nice functions for parsing, so look for them also!
RamsTheDonAuthor Commented:
Thanks guys i'll try all your suggested solutions.
I'll give more feedback in a bit, but please let me know if you've got any addditions to make to the above comments.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.