Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Scanner not working?

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Scanner not working?

    Okay, so I am making a tower defense game and I have a scanner to edit the levels! But it's not working! No errors are showing!

    Scanner :
    import java.io.*;
    import java.util.*;

    public class Save {
    public void loadSave (File loadpath) {
    try{
    Scanner loadScanner = new Scanner(loadpath);

    while(loadScanner.hasNext()) {
    for(int y=0;y<Screen.room.block.length;y++) {
    for(int x=0;x<Screen.room.block[0].length;x++) {
    Screen.room.block[y][x].groundID = loadScanner.nextInt();
    }
    }
    for(int y=0;y<Screen.room.block.length;y++) {
    for(int x=0;x<Screen.room.block[0].length;x++) {
    Screen.room.block[y][x].airID = loadScanner.nextInt();
    }
    }
    }

    loadScanner.close();
    } catch(Exception e) { }
    }
    }


    Values

    public class Value {
    public static int groundGrass = 0;
    public static int groundroad = 2;
    public static int airAir = 1;
    }


    Level
    0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0

    -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
    -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
    -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
    -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
    -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
    -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
    -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
    -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1


    Please help i've been working on this error for 3 days!


  2. #2
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Scanner not working?

    how does it NOT working? doesnt it show any output? doesnt it take any input? would you mind to wrap your codes in code tags

  3. #3
    Junior Member
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Scanner not working?

    Quote Originally Posted by chronoz13 View Post
    how does it NOT working? doesnt it show any output? doesnt it take any input? would you mind to wrap your codes in code tags
    Oh, lemme put it in better detail to create the levels i am using the variables and the variable for grass is 0 whitch is what it's showing at the moment but when I change the 0's it's supposed to change textures but it's not doing that. And idk how to work this forums :3 Sorry

  4. #4
    Member
    Join Date
    Jul 2012
    Posts
    83
    My Mood
    Cynical
    Thanks
    3
    Thanked 9 Times in 9 Posts

    Default Re: Scanner not working?

    The forum faq will tell you how to "work" the forum, but for one, place [code] [/code] tags around your code, not bold or underline tags, because the code in your first post is near impossible to read.

  5. #5
    Junior Member
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Scanner not working?

    Quote Originally Posted by Fubarable View Post
    The forum faq will tell you how to "work" the forum, but for one, place [code] [/code] tags around your code, not bold or underline tags, because the code in your first post is near impossible to read.
    Scanner :
    pastebin.com/6nd5Vr5a

    Variables :
    pastebin.com/pg7mY8ZH

    Level :
    pastebin.com/GeSC4HDQ

  6. #6
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Scanner not working?

    theres a FAQ clickable text on top, below of the home page buttons, I inserted it for you,
    and please just like what fubarable have said, please wrap your codes in codes tags [code] your codes inserted here in between of these 2 things [/code], and also, I really dont get the flow of your program.

Similar Threads

  1. Scanner not working properly.
    By kookevk in forum What's Wrong With My Code?
    Replies: 9
    Last Post: January 25th, 2012, 10:14 PM
  2. Scanner help
    By sp11k3t3ht3rd in forum Java Theory & Questions
    Replies: 3
    Last Post: June 22nd, 2011, 11:55 AM
  3. Scanner/FileReader help
    By JohnTravoltaire in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 28th, 2011, 12:28 AM
  4. Help With Scanner
    By jtphenom in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: October 12th, 2009, 08:49 PM
  5. Replies: 4
    Last Post: January 27th, 2009, 12:03 AM