My code worked perfectly before when separating by comma, and now it won't work for semicolon!
By comma:
public void loadXXXData() {
InputStream is = getResources().openRawResource(R.raw.xxxdata);
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
try {
String line;
String[] RowData;
RowData = new String[XXXVARNUM];
for(int i=0;i<NUMBEROFXXX;i++){
//Read the line.
line = reader.readLine();
//Cut the line up.
RowData = line.split(",",XXXVARNUM);
for(int j=0;j<XXXVARNUM;j++){
//Distribute the line into a 2D array.
XXX[i][j] = RowData[j];
}
}
//Populate forms
setCurrentXXX(XXX);
}
catch (IOException ex) {
Log.v("XXXdex", "I/O Exception: Could not read from the I/O stream.");
}
finally {
try {
//Close the stream
is.close();
}
catch (IOException e) {
Log.v("XXXdex", "I/O Exception: Could not close the I/O stream.");
}
finally {
}
}
}
finally {
}
}
By semicolon:
public void loadItemData() {
InputStream is = getResources().openRawResource(R.raw.items);
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
try {
String line;
String[] RowData;
RowData = new String[ITEMVARNUM];
for(int i=0;i<NUMBEROFITEMS;i++){
//Read the line.
line = reader.readLine();
//Cut the line up.
RowData = line.split(";",ITEMVARNUM);
for(int j=0;j<ITEMVARNUM;j++){
//Distribute the line into a 2D array.
ITEM[i][j] = RowData[j];
}
}
//Populate forms
setCurrentItem(item);
}
catch (IOException ex) {
Log.v("XXXdex", "I/O Exception: Could not read from the I/O stream.");
}
finally {
try {
//Close the stream
is.close();
}
catch (IOException e) {
Log.v("XXXdex", "I/O Exception: Could not close the I/O stream.");
}
finally {
}
}
}
finally {
}
}
A sample from the xxxData:
1,dinosaur,Grass,Poison,45,49,49,65,65,45,Supergrow,,DrPhyll,64,0,0,0,1,0,0,45,0.7 m,6.9 kg,Seed
...Loads perfectly.
A sample from the itemData:
Antidote;A spray-type medicine. It lifts the effect of poison from one XXX.;Route 3, Pinwheel Forest, Pinwheel Forest, Pinwheel Forest (With Dowsing Machine), Icirrus City Shop Route 9, Accumula Town, Striaton City, Nacrene City, Castelia City, Nimbasa City, Driftveil City, Mistralton City, Icirrus City, Opelucid City, XXX League, Lacunosa Town, Undella Town, Black City, White Forest
...Will not split correctly. What is up with that? I've scoured the forums looking for regex expressions that represent ";", but nothing will work. I keep getting an arrayIndexOutOfBounds exception because String.split isn't separating my string into the correct number of strings.