Hi! I've written function that writes to one of eight files. It writes one of the strings, which is associated with a file to that file.
There is also a similar one, it just reads from that file and returns it.
When I run the program, it does everything correctly, it just doesn't read correctly (it doesn't seem to write anything at all...) what it does read is [C@1d6096. It reads this EVERY time.
Function Def:
void writeFile(int no) {
folder.mkdir();
System.out.println("Directory Created at: " + folder.getAbsolutePath());
FilesInit();//this just makes the files, assigns the writers the appropriate values.
try {
bw = new BufferedWriter(new FileWriter(read[no]));
} catch (IOException e) {
e.printStackTrace();
return;//there was error, save time- exit to main (or whatever is calling)
}
try {
bw.write(files[no]);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
The Reader is:
String readFile(int no) {
folder.mkdir();
System.out.println("Directory Created at: " + folder.getAbsolutePath());
FilesInit();
char[] read2 = new char[1000];
try {
br = new BufferedReader(new FileReader(read[no]));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
br.read(read2);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return read2.toString();
}
If you'd like to see any other part of the code, just ask.
Thanks,
JT