I want to Read a file and store it in an array, then split up the array everywhere there is a }, so that each item in the array contains the string split up. Here is what I mean,
My file contains stuff like this:
[
{
"sample1": {
"color": "red",
"date": "2011,
"name": "george"
}
},
{
"sample2": {
"color": "red",
"date": "2012",
"name": "phil"
}
},
I want to read this file, have have for example the oth element in the array to represent
{
"sample1": {
"color": "red",
"date": "2011,
"name": "george"
}
},
and for element number one to represent
{
"sample2": {
"color": "red",
"date": "2012",
"name": "phil"
}
},
Now I am not too sure how to do this, I don't know what the size of my array will be and I am not sure how I will access each element of my array, I have started off with this so far
String str;
char[] getArray;
FileReader fr = new FileReader("/sampleProject");
BufferedReader br = new BufferedReader(fr);
br.readLine();
while ((str = br.readLine()) != null) {
str.toCharArray();
str.split("},");
}
System.out.println("Here it is" + str);
br.close();
}