right now i'm using this code to load the following text file into a HashMap
but i want to upload the .txt
file to dropbox and have it read from the dropbox link, is this possible?
code i'm using to load the txt
file locally.
package com.cindra.utilities;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class PriceManager {
private static Map<Integer, Double> itemPrices = new HashMap<Integer, Double>();
public static void init() throws IOException {
final BufferedReader file = new BufferedReader(new FileReader("./data/items/prices.txt"));
try {
while (true) {
final String line = file.readLine();
if (line == null) {
break;
}
if (line.startsWith("//")) {
continue;
}
final String[] valuesArray = line.split(" - ");
itemPrices.put(Integer.valueOf(valuesArray[0]), Double.valueOf(valuesArray[1]));
}
Logger.log("Price Manager", "Successfully loaded "+itemPrices.size()+" item prices.");
} catch (final IOException e) {
e.printStackTrace();
} finally {
if (file != null) {
file.close();
}
}
}
public static double getPrice(int itemId) {
try {
return itemPrices.get(itemId);
} catch (final Exception e) {
return 0;
}
}
}
Thanks for help.