Having Scanner troubles.

Discussion in 'Plugin Development' started by iPhysX, Dec 21, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    iPhysX

    I would like to read the entire contents of a file and print it as a string.
    I'm having some issues.
    I realize this is elementary, but I just don't have it down.

    Thanks for helps!
     
  2. I could be a troll and tell you to google search but instead I will just copy the code I used to read keys in AData. You should be able to pull the bits and pieces you need from that :)
    PHP:
    public HashMap<StringObjectread() {
            
    HashMap<StringObjecttempKeys = new HashMap<StringObject>();
            try {
                
    FileInputStream in = new FileInputStream(this.target);
                
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
                
    String strLine;
                while ((
    strLine br.readLine()) != null) {
                    
    String[] prop strLine.split(":");
                    if (
    prop.length == 2) {
                        
    String[] locs prop[1].split(",");
                        if (
    locs.length == 4) {
                            
    World w Bukkit.getServer().getWorld(locs[0]);
                            
    double xyz;
                            
    Double.parseDouble(locs[1]);
                            
    Double.parseDouble(locs[2]);
                            
    Double.parseDouble(locs[3]);
                            
    tempKeys.put(prop[0], new Location(wxyz));
                        } else if (
    strLine.contains(":") && strLine != null && !strLine.contains("#")) {
                            
    String[] property strLine.split(":");
                            
    tempKeys.put(property[0], property[1]);
                        }
                    }
                }
                
    in.close();
            } catch (
    IOException iox) {
                
    iox.printStackTrace();
            }
            return 
    tempKeys;
        }
     
  3. Offline

    Lolmewn

    If you need any more help with this, PM me. Or quote, works the same. Or whatever :) Or skype :D
    Oh so many ways to contact me!
     
  4. Offline

    iPhysX

    @Adamki11s
    troll.
    But thanks.
    G00gle didn't help much.
     
    Adamki11s likes this.
Thread Status:
Not open for further replies.

Share This Page