This is my first post on joining the forum. I feel encouraged that there are people out there to discuss and help.
I have been trying to create a mini project that takes an input file text file and performs some string manipulations on it using java code and stores the updated contents in an output file.
1.Count the no of characters in each line.
2.Count the number of 4's in each line.
3.Replace 'this' with 'that'
4.Reverse line by line
My code prints the total number of characters and 4's in the file and not line by line. Could anyone suggest me on this please.
My function for counting number of 4's:
My function for counting total number of characters:
My main function is:
Also I would like the result from file1.replaceString(file1.copy()); in my main function to be passed as an argument to the following reverse function in main like file1.reverse(file1.replaceString(file1.copy())); But it wouldn't work. T
Aasha Karthik wrote:This is my first post on joining the forum...
Welcome to JavaRanch Aasha.
First: When you're posting code, please UseCodeTags (←click). I've added them for you this time; see how much better it looks?
Also: avoid very long lines, and make sure your code is indented properly after you've pasted it. Yours is a bit off, but you can use the 'Edit' button to clean it up if you like, and the 'Preview' button to see what it will look like before you post. I'd also suggest NOT using tabs for indentation.
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here