Reading in from a txt file with java

Discuss all aspects of programming here.

Moderator: The Mod Squad

Reading in from a txt file with java

Postby ~Rob » Wed Mar 15, 2006 7:20 am

Can anybody help?

I'm trying to read in ints from a txt file, but the ints need to be assigned in a special way if the word start or goal is on the next line. How can I read the line and if the next line is one of the words use the ints?

Code: Select all
else while(inReader != null){
                    try{
                        inFile.mark(3);
                        inFile.readLine();
                        if (inFile.readLine() == "Start"){
                            inFile.reset();
                            String pos = inFile.readLine();
                            char i = pos.charAt(0);
                            char j = pos.charAt(2);
                            inFile.readLine();
                            inFile.mark(3);
                        }


That's what I'm trying at the moment. Any ideas?
Image
Jocuri cu impuscaturi si alte genuri, pentru toate varstele doar pe acest link - distractie si amuzament garantat!
~Rob
Black Belt 4th Degree
Black Belt 4th Degree
 
Posts: 4941
Joined: Sun Dec 28, 2003 8:26 pm
Location: Norwich, UK

more information

Postby keene » Tue Mar 28, 2006 12:07 pm

Not sure I understand what you are trying to do.

Can you provide an example of the type of data in your text file?
keene
Initiate
Initiate
 
Posts: 41
Joined: Thu Jan 30, 2003 8:42 pm

Postby ~Rob » Tue Mar 28, 2006 12:09 pm

Well I've done it now, it was to read in numbers seperated by a space from a text file. I'm now working on a maze game built in java, nearly there now!
Image
Jocuri cu impuscaturi si alte genuri, pentru toate varstele doar pe acest link - distractie si amuzament garantat!
~Rob
Black Belt 4th Degree
Black Belt 4th Degree
 
Posts: 4941
Joined: Sun Dec 28, 2003 8:26 pm
Location: Norwich, UK


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron