Note that there are some explanatory texts on larger screens.

plurals
  1. POIf found, return value one tab over [java]
    text
    copied!<p>I've successfully created an item scanner for my game.</p> <p>Here is my code: </p> <pre><code>import java.io.*; import java.util.*; public class ItemScanner { public static void main(String args[]) { System.out.print("Enter item to find: "); Scanner sc = new Scanner(System.in); find(sc.nextLine()); } public static void find(String delim) { File dir = new File("accounts"); if (dir.exists()) { String read; try { File files[] = dir.listFiles(); for (int i = 0; i &lt; files.length; i++) { File loaded = files[i]; if (loaded.getName().endsWith(".txt")) { BufferedReader in = new BufferedReader(new FileReader(loaded)); StringBuffer load = new StringBuffer(); while ((read = in.readLine()) != null) { load.append(read + "\n"); } String delimiter[] = new String(load).split(delim); if(delimiter.length &gt; 1) { System.out.println("Found " + (I don't know how to read 1 tab over - 1) + " time(s) in " + loaded.getName() + "!"); } } } } catch (Exception e) { e.printStackTrace(); } } else { System.out.println("error: dir wasn't found!"); } } } </code></pre> <p>I'm on the last step of making my life easier when it comes to finding how many of this item the player has.</p> <p>here's the scenario:</p> <p>Search Item: 6570</p> <p>Found [x] time(s) in Account.txt!</p> <p>This is how the layout of the items are</p> <p>account-item = 6570 1</p> <p>It's read like this: 6570 is the item, then [tab] , 1 equals how much of the item that user has.</p> <p>So if it says</p> <p>account-item = 6570 24</p> <p>The user has 24 of that item.</p> <hr> <p>Problem:</p> <p>I simply do not know how to return the value of the item from 1 tab over.</p> <p>So if I search for 6570, and if it is found, how would i get the amount of the item being found? Here's my code to return the items</p> <pre><code>String delimiter[] = new String(load).split(delim); if(delimiter.length &gt; 1) { System.out.println("Found " + (I don't know - 1) + " time(s) in " + loaded.getName() + "!"); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload