Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with reading txt file into 2d array

 
Liana Norpunova
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone!

I have a problem with reading data from the txt file into the 2d array. In general, the above code is workable. The only thing that doesn't work is: userdata[row][j] = tokens[j]; The problem is that my array "userdata" gets values "null". However, if I replace this code with "System.out.println(tokens[j]);", then I can see the values from the file "UserDataFile.txt". What is wrong in my code?

 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And how is this a Swing / AWT / SWT / JFace question?
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It isn't. Off to Java in General we go!
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do you define userdata? (It's harder to help when we don't have all the information.)
 
Liana Norpunova
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! I've already solved this problem. I just read from this array into JTable, and everything worked fine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic