Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (780)
Games in Android Showcase (233)
games submitted by our members
Games in WIP (857)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Can anyone show me how to read a  text file?  (Read 1717 times)
0 Members and 1 Guest are viewing this topic.
Offline javanewb

Junior Newbie

Java games rock!

« Posted 2004-10-17 15:51:50 »

hi there Smiley

i have installed java 1.4.2 and i cant figure out how to read from a text file that ill be using for a map in some rpg game..tried a lot of examples that i found on the net but they where all deprecated or something. i have programming experience in basic, pascal and c languages but im so new to java  Embarrassed !
i already tried some tutorials but the io part seems complicated.

i want to read the text from a file into an array(in a simple way)

for example i would have numbers in the text file
1  3   2
2  1   1
1  3   4

would be and array of 9, each one represents a tile in the game

please help  Huh
Offline blahblahblahh

JGO Coder

Medals: 1

« Reply #1 - Posted 2004-10-17 16:18:46 »

Firstly, google for the "java tutorials" by "Sun" (also known as Trails or JFC etc) and do them all - these are the free official java tutorials.

You definitely don't want to store your map like that, though. But you can worry about more sensible (and easier to do) ways of storing your map once you've learnt hte basics of htose tutorials.

(you will probably want to use either XML (DOM) or a binary-format file for maps - or just download something like Mappy (google for it) and let it take care of the work)

malloc will be first against the wall when the revolution comes...
Offline javanewb

Junior Newbie

Java games rock!

« Reply #2 - Posted 2004-10-17 23:08:04 »


thx im finally getting somewhere with these tutorials
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cep21

Junior Devvie

Java games rock!

« Reply #3 - Posted 2004-10-18 00:01:05 »

Install java 1.5 and use the new Scanner class.  It's very good for C++ style reading.

//Scanner s=new Scanner(;
// Scanner s=new Scanner(new File("input.txt"));


and so on.
Pages: [1]
  ignore  |  Print  

hadezbladez (1098 views)
2018-11-16 13:46:03

hadezbladez (501 views)
2018-11-16 13:41:33

hadezbladez (1090 views)
2018-11-16 13:35:35

hadezbladez (252 views)
2018-11-16 13:32:03

EgonOlsen (2543 views)
2018-06-10 19:43:48

EgonOlsen (2743 views)
2018-06-10 19:43:44

EgonOlsen (1545 views)
2018-06-10 19:43:20

DesertCoockie (2249 views)
2018-05-13 18:23:11

nelsongames (2083 views)
2018-04-24 18:15:36

nelsongames (2778 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!