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

what it does read is [C@1d6096.

Not sure what you mean by "read" The string: [C@1d6096 looks like the output from a print.
The [C@1d6096 is the String returned by the Object class's toString method for an array([) of chars(C) at memory location 1d6096.

Look at the String class for how convert an array of chars to a String.
Hint its a constructor.

You could also use a different method to read it

look at this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.