Basically, what I'm trying to do, is get the item ID, and set a price from a ini, basically like: itemid:price but, i cannot simply do item.getId().toString(). I'm trying to get item What can I do to make it a string?
public static void getBuyPrice(Item item) {
try {
String itemId = item.getId().toString();
BufferedReader br = new BufferedReader(new FileReader(new File(
"./data/prices.ini")));
String line;
while ((line = br.readLine()) != null) {
if (line.equals(itemId)) {
String[] split = line.split(":");
item.getDefinitions().setValue(Integer.parseInt(split[1]));
}
}
br.close();
} catch (Throwable e) {
System.err.println(e);
}
}
That is my code, (of course I have the error at item.getId().toString()), What can I do to convert that to a string?
Primitive types do not have methods, as they are not objects in Java. You should use the matching class:
Integer.toString(item.getId());
String itemId = Integer.toString(item.getId());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With