Jump to content

Snuts

Members
  • Posts

    1
  • Joined

  • Last visited

  • Feedback

    0%

Profile Information

  • Gender
    Male

Recent Profile Visitors

579 profile views

Snuts's Achievements

Newbie

Newbie (1/10)

1

Reputation

  1. Here's a small snippet I use for reading accounts from a file, you should be able to take from it what you need. private void readAccounts() { // The name of the file to open. String fileName = "accounts.txt"; // This will reference one line at a time String line = null; try { // FileReader reads text files in the default encoding. FileReader fileReader = new FileReader(getDirectoryData() + fileName); // Always wrap FileReader in BufferedReader. BufferedReader bufferedReader = new BufferedReader(fileReader); while((line = bufferedReader.readLine()) != null) { String[] lineInfo = line.split(":"); vars.addToAccounts(lineInfo); } // Always close files. bufferedReader.close(); vars.setCheckedFile(true); } catch(FileNotFoundException ex) { log("Accounts file not found, stopping script"); stop(false); } catch(IOException ex) { log("Error reading file, stopping script"); stop(false); } } Probably not the best way to do this but works none the less.
×
×
  • Create New...