Results 1 to 5 of 5
  1. #1
    werner291 is offline Member
    Join Date
    Sep 2011
    Posts
    14
    Rep Power
    0

    Default *please ignore* (turns out I misplaced a file)

    It looks like I accidentally using the wrong file. Sorry.

    Hello, this piece of code only runs once. There are several lines in the file being read, however.
    Why does this not read the whole file?

    File being read:
    WALL 350 200 800 600
    WALL 350 250 800 600
    WALL 350 300 800 600

    Java Code:
    private static void LoadLevel(String level, List<Entity> list_entities) {
    		try {
    		    BufferedReader in = new BufferedReader(new FileReader(new File("test.yml")));
    		    
    		    String str;
    		    while ((str = in.readLine()) != null) {
    		    	System.out.println(str);
    		    	
    		    	String Args[] = str.split(" ");
    		    	
    		    	if (Args[0].equalsIgnoreCase("WALL")){
    		    		Entity wall = new Wall("wall.gif",Integer.parseInt(Args[1]),Integer.parseInt(Args[2]));
    		    		list_entities.add(wall);
    		    	}
    		    }
    		    in.close();
    		} catch (IOException e) {
    			
    		}
    	}
    Last edited by werner291; 09-28-2011 at 01:49 PM. Reason: Discovered the problem

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: Only one wall block?

    Where does the layout manager place the components you are adding to the frame's content pane?

  3. #3
    werner291 is offline Member
    Join Date
    Sep 2011
    Posts
    14
    Rep Power
    0

    Default Re: Only one wall block?

    @Norm I almost completely rewrote that piece of code, and now I'm shure it's the file being read incorrectly, because when I replace the while loop with a for loop, it executes correctly. PS: I'm completely new to Java.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: Only one wall block?

    I don't recognize the code you have there now.

    Can you explain what is the problem now? Show the console from when the code executes.

  5. #5
    werner291 is offline Member
    Join Date
    Sep 2011
    Posts
    14
    Rep Power
    0

    Default Re: Only one wall block?

    Looks like I was editing the wrong file. text.txt apparently had a copy in another file, the one I was editing. The program actually recieved a file with just one line.

    Sorry for wasting your time with such a stupid mistake.

Similar Threads

  1. block url
    By thedevilz in forum New To Java
    Replies: 1
    Last Post: 09-16-2010, 10:55 PM
  2. Wall bug on physics simulation
    By mustachMan in forum New To Java
    Replies: 2
    Last Post: 07-14-2010, 05:56 AM
  3. Someone plz help... how to block inputs
    By waklo99 in forum New To Java
    Replies: 4
    Last Post: 03-15-2010, 06:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •