Reputation: 402
I am getting nothing out in my console from my System.out.println()
in the following code:
LinkedList<Element> ls = count(list);
File outFile = new File(args[1]);
FileWriter fw = new FileWriter(outFile);
BufferedWriter bw = new BufferedWriter(fw);
for(int i = 0; i < ls.size(); i++) {
bw.write((int) ls.get(i).data);
System.out.println("Written out " + ls.get(i).data);
}
bw.flush();
bw.close();
Element
object is only a class with an int key;
and an Object data;
The BufferedWriter
is writing out to the file as it should, but my Console in Eclipse doesn't get the System.out.println();
calls. When I run it in debug mode with breakpoint at bw.write()
I keep pressing F8 (hotkey to resume), until the BufferedWriter
is done, but nothing gets into the Console. Any ideas of why?
Upvotes: 0
Views: 716
Reputation: 1
Try outputting the variables for the for loop such as the ls.size(), if nothing is being output there then your code isn't being called at all but if it is then you should be able to figure out what is wrong.
since we don't know what is in ls we don't know if it may even be empty
so to help us try putting
System.out.println("List: " + ls);
System.out.println("List size: " + ls.size());
just before the for loop and tell us the outputs.
Upvotes: 0
Reputation: 201537
First, please don't use the System console for your logging. Second, add a call to flush()
. Finally, make sure you add the same cast you used before (or just save it to a variable).
int payload = (int) ls.get(i).data;
bw.write(payload);
System.out.println("Written out " + payload);
// Or,
// System.out.println("Written out " + ((int) ls.get(i).data));
System.out.flush();
Upvotes: 1