This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am having problems reading from a JList, my application consists in adding text line by line from a text file to a JList, ..and the problem that i am facing is...how can i read elements from Jlist, character by character .... help please....
Joined: May 28, 2009
this is the code that reads form txt:
where "model" is Jlist model
and i have tried to read from list:
the line i'm tryng to read is something like: "S LLLL 0.2"
I have to say it is a bit difficult to follow your code as it doesn't seem to be complete (for instance where do the for loops for k and j finish?).
But looking at the code as it stands and at the error message it is basically saying that you are trying to reference a part of the string ('s1') that does not exist. You should be able to see this if you output the length of the string 's1' and the value of k where it fails (you'll probably find that k >= s1.length()).
<hint>Remember that String.charAt(int) references the string as it would a list so characters are retreived from position 0 rather than 1.</hint>
Also not sure if you have been asked to use for loops for your project but if not you may want to have a look in using StringTokenizer, this should take a lot of the pain out of what you are trying to do.