New line in .txt file how?

Discussion in 'Plugin Development' started by 8803286, Feb 23, 2012.

Thread Status:
Not open for further replies.
  1. I have tryed everything then i mean EVERYTHING but do it work , no it dosen't.
    And i have searched for like 3 days on internet.

    if(args[0].equalsIgnoreCase("SetTp")){
    if (args.length > 1) {

    int locX = player.getLocation().getBlockX();
    int locY = player.getLocation().getBlockY();
    int locZ = player.getLocation().getBlockZ();

    String obj = "Name: " + args[1] + " " + locX + " " + locY + " " + locZ;
    String path = plugin.getDataFolder().getPath() + File.separator + "Tps.txt";

    try {

    BufferedWriter bw = new BufferedWriter(new FileWriter(path));
    bw.write(obj);
    sender.sendMessage(ChatColor.BLUE + args[1] + " sets to: " + locX + " " + locY + " " + locZ );
    bw.flush();
    bw.close();
    } catch (IOException e) {
    e.printStackTrace();
    }

    }
    }

    can somone help me to fix that?
    i have send all of the script for the tp
     
  2. Offline

    TopGear93

    im not sure if im correct about this but try and make a HashMap and save the player with x,y,z

    HashMap<string> hashmapnode = new ArrayList<string>;

    <pluginname>.hashmapnode.add(player.getName()+ x + y + z);

    <pluginname>.hashmapnode.get(player.getName() + x + y + z);

    using .add() creates a new line everytime
     
  3. Offline

    Lolmewn

    You have to read the whole file, store the data in a HashMap<Integer,String> (Integer to get the position back, use map.size() to set them), then after it's done reading delete the file.
    Create a new file, write all data back and add your newly added data.
     
  4. Offline

    stelar7

    so...
    if the first argument is settp and there's more than 1 argument, save the 2nd argument and the x,y,z to a file...
    new line is
    Code:
    bw.newLine();
    if thats what you're looking for...
     
  5. YAY it's work but you need to add path, true
     
  6. Offline

    stelar7

    I just cleaned the code you posted, didn't make any changes.. :p
     
  7. you know what \n means?
     
  8. Offline

    stelar7

    ferrybig do you always post in solved threads? or just the ones I look in?
    anyways... \n is newline
     
  9. \n makes an new line in a file too, but I didn't say [solved] at the topic
     
  10. Offline

    hatstand

    He doesn't read the thread before replying. Ever.
     
  11. Offline

    Smex

    You could try my XemDB for storing values :)
     
Thread Status:
Not open for further replies.

Share This Page