Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Merge two text files and count number of characters.

 
Grey Joseph
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So here's a bit about the details.
I need to read the contents of file A, and B and store it in file C by joining the contents of A and B and also counting the number of letters/characters present in it.
I've come up with this so far.
Can someone help me here.
Any input would be great.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Grey,
Welcome to CodeRanch!

If you are using Java 7, there is an easier way to do this. I'll assume that you aren't (or this is a homework assignment and you haven't learned the Java 7 way of reading a file yet.)

Let's start with one thing at a time. Making the code compile. In future posts, it helps to say what the errors are from the compiler. You've got a number of them. It helps to write code in smaller pieces and fix the errors as they come up. Let's start with this smaller version of your code.

Can you fix the compiler errors and run it to output "2"? I see five compiler issues and a logic error. Give it a shot. Try to fix the errors your compiler gives you one at a time. When you hit one that you don't know what to do with, copy the error and post it as a reply to this thread. Once you fix the compiler error, see if you explain the logic error. Even if you can't fix all of these, the process will help you learn more about Java and help you with future programs. And don't worry, we are hear to hold your hand.

Here's a hint to start: Java is case sensitive. See anything about "string" that's different in your code than the example you started with?


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic