Results 1 to 3 of 3
- 05-24-2011, 10:10 PM #1
Member
- Join Date
- May 2011
- Posts
- 32
- Rep Power
- 0
Selecting what to read in a .txt files
Hello and welcome,
long story short my friends and I play a DnD type game and it has become more like a universe more than spawning 30+ people casuals and hardcores alike. We are trying to get all this organized and easily able to send to everyone there character sheets and get so people from across country can still play. so i took it up and started to learn programing! yay me!
now to the problem:
I'm currently making the character sheets in a word .txt document and being able to read them. problem i have at the moment is it is always reading the first in a line or a row.
I cannot get it to "Fish" for a piece of information i need. like exp.
NAME: Mokomi Jay Tas.
I do not want the NAME:
This will also help in the future when I add items,spells and abilities.
please and thank you in advance ^.^
Java Code:public void readPc(){ while(s.hasNext()){ try{ String a=s.next(); String b=s.next(); String c=s.next(); String f=s.next(); System.out.printf("%s\t%s\t%s\n",a,b,c); }catch(Exception d){ System.out.println("Failed to read Charater Sheet!");}} }
- 05-24-2011, 11:00 PM #2
One comment on your code: You only have one hasNext() call and there are 4 next() calls.
What happens when you execute the posted code with the input shown?
What is the output from the printf?
If you know you want to ignore the first token, why not do that. Read it and ignore it.Last edited by Norm; 05-24-2011 at 11:02 PM.
- 05-25-2011, 01:20 AM #3
Member
- Join Date
- May 2011
- Posts
- 32
- Rep Power
- 0
hasNext() is nice because it goes though the row and the while loop makes new rows but that is all place holders atm.
what i'm trying to do is get it so it reads all words after the NAME: but not in the next line.
NAME: Mokomi J Tas
RACE: Human
LEVEL: 18
HEALTH: 2200/2300
MANA: 1700/1700
AURA: 0
this is currently the code. yes i can have it just eat it all have each string/int saved each time i pull, but that feels like a huge waste. and when i start putting gear they have/inventory/inventory that is shown/etc i won't be able to show that. I do not know how to look up a search for the what is after the NAME: to place in the title window etc.
Similar Threads
-
Read from two files
By globo in forum New To JavaReplies: 1Last Post: 01-29-2011, 10:25 PM -
Files, cannot read!
By LennyKosmos in forum New To JavaReplies: 2Last Post: 10-02-2010, 01:35 PM -
Selecting Files in a folder
By ravjot28 in forum New To JavaReplies: 1Last Post: 02-26-2010, 04:25 PM -
Read/Write Files
By FlyNn in forum New To JavaReplies: 3Last Post: 02-06-2010, 08:45 PM -
Read and Open *.txt Files? help!!
By ashton in forum New To JavaReplies: 9Last Post: 11-01-2009, 03:42 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks