• Post Reply Bookmark Topic Watch Topic
  • New Topic

Please help me with this program - Not looking for free handout.  RSS feed

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I am writing a program that splits up text in one file, then sends that text out to two different files.

Ex. Say FileA.txt has
aaaaaaaa
bbbbbbbb
ccccccccc
dddddddd
eeeeeeee

This program would create two new files, say, FileB and FileC and then print interwoven lines of text in each.

After the program ran, it would have written to FileB:
aaaaaaaa
ccccccccc
eeeeeeee

and it would printed to FileC:
bbbbbbbb
dddddddd

Here is the code. Every time I run it I get back the IOException it throws, "Please make sure there are 3 files". The file from argument 0 was created and has text in it, so I know it isn't an issue of missing files. Also, since the program is creating the files at args 1 and 2, it does not matter if they do not exist. Thank you for looking at this!


 
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The Exception class has a printStackTrace() method. If you call that in the catch clause, it can be used to figure out which method call triggered the exception.

Henry
 
Matrica Kovolunchy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok,first of all, thank you! Second, I solved the exception error (with your help), but now it will not print the information to the Files. It doesn't give any errors... but it also doesn't print to the files. I've updated the original code.
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simple debugging: After each read instruction, print the line read to System.out. Put another print instruction after each write instruction. Then you can see the program flow and follow it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!