BufferedWriter bw = new BufferedWriter("./test.txt");
bw.write("yayaya");
bw.write("\t");//Tabbing
bw.newLine();
bw.flush();
bw.close();
?
|
Well I'm looking towards storing different things in a file, which I know how to do, I just don't know how to store them on the same line of text in the same file.
Like..
I would think you would need to use a .cfg file but I don't know how to do that.Code:PlayerName SomethingElseHere
But when you store them in the same line, your operation reads them seperate
SO my question is.
How would I store information in the same file on the same line of text, but when I use something that reads from the file, it reads from the same line and uses them seperate.
Like I want
"+PlayerName+" is "+SomethingElseHere+".
Hope you understand me O_O
I think I lost myself <_<
BufferedWriter bw = new BufferedWriter("./test.txt");
bw.write("yayaya");
bw.write("\t");//Tabbing
bw.newLine();
bw.flush();
bw.close();
?
Check out NpcHandler and see how autospawn is loaded
Don't understand that. Not one bit.Code:public boolean loadAutoSpawn(String FileName) { String line = ""; String token = ""; String token2 = ""; String token2_2 = ""; String[] token3 = new String[10]; boolean EndOfFile = false; int ReadMode = 0; BufferedReader characterfile = null; try { characterfile = new BufferedReader(new FileReader("./" + FileName)); } catch (FileNotFoundException fileex) { Misc.println(FileName + ": file not found."); return false; } try { line = characterfile.readLine(); } catch (IOException ioexception) { Misc.println(FileName + ": error loading file."); return false; } while (EndOfFile == false && line != null) { line = line.trim(); int spot = line.indexOf("="); if (spot > -1) { token = line.substring(0, spot); token = token.trim(); token2 = line.substring(spot + 1); token2 = token2.trim(); token2_2 = token2.replaceAll("\t\t", "\t"); token2_2 = token2_2.replaceAll("\t\t", "\t"); token2_2 = token2_2.replaceAll("\t\t", "\t"); token2_2 = token2_2.replaceAll("\t\t", "\t"); token2_2 = token2_2.replaceAll("\t\t", "\t"); token3 = token2_2.split("\t"); if (token.equals("spawn")) { newNPC(Integer.parseInt(token3[0]), Integer.parseInt(token3[1]), Integer.parseInt(token3[2]), Integer.parseInt(token3[3]), Integer.parseInt(token3[4]), Integer.parseInt(token3[5]), Integer.parseInt(token3[6]), Integer.parseInt(token3[7]), Integer.parseInt(token3[8]), GetNpcListHP(Integer.parseInt(token3[0])), true); } } else { if (line.equals("[ENDOFSPAWNLIST]")) { try { characterfile.close(); } catch (IOException ioexception) {} return true; } } try { line = characterfile.readLine(); } catch (IOException ioexception1) { EndOfFile = true; } } try { characterfile.close(); } catch (IOException ioexception) { } return false; }
BufferedWriter bw = new BufferedWriter("./test.txt");
bw.write(playerName);
bw.write("\t");//Tabbing
bw.write(somethingelse);
bw.newLine();
bw.flush();
bw.close();
All it's really doing is splitting the tabs into seperate parts. Which sorts them into an arrayCode:line = line.trim(); int spot = line.indexOf("="); if (spot > -1) { token = line.substring(0, spot); token = token.trim(); token2 = line.substring(spot + 1); token2 = token2.trim(); token2_2 = token2.replaceAll("\t\t", "\t"); token2_2 = token2_2.replaceAll("\t\t", "\t"); token2_2 = token2_2.replaceAll("\t\t", "\t"); token2_2 = token2_2.replaceAll("\t\t", "\t"); token2_2 = token2_2.replaceAll("\t\t", "\t"); token3 = token2_2.split("\t"); if (token.equals("spawn")) { newNPC(Integer.parseInt(token3[0]), Integer.parseInt(token3[1]), Integer.parseInt(token3[2]), Integer.parseInt(token3[3]), Integer.parseInt(token3[4]), Integer.parseInt(token3[5]), Integer.parseInt(token3[6]), Integer.parseInt(token3[7]), Integer.parseInt(token3[8]), GetNpcListHP(Integer.parseInt(token3[0])), true);
Very simple.
Well How would I make it like that? And have something that reads from it?
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |