Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
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 745 times)
0 Members and 1 Guest are viewing this topic.
Offline javanewb

Junior Newbie




Java games rock!


« Posted 2004-10-17 17: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


http://t-machine.org


« Reply #1 - Posted 2004-10-17 18: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-18 01:08:04 »

Smiley

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 Member




Java games rock!


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

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

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

s.nextInt();
s.nextFloat();

and so on.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (125 views)
2013-05-17 21:29:12

alaslipknot (133 views)
2013-05-16 21:24:48

gouessej (163 views)
2013-05-16 00:53:38

gouessej (156 views)
2013-05-16 00:17:58

theagentd (168 views)
2013-05-15 15:01:13

theagentd (153 views)
2013-05-15 15:00:54

StreetDoggy (197 views)
2013-05-14 15:56:26

kutucuk (221 views)
2013-05-12 17:10:36

kutucuk (220 views)
2013-05-12 15:36:09

UnluckyDevil (224 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.062 seconds with 20 queries.