Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

goes through each word in wordlist, find character to replace and replace it.

Posted on 2004-10-26
1
Medium Priority
?
246 Views
Last Modified: 2010-03-31
i have a list of words to read from.
how can i search each line, find the character to replace(in charsToReplace) and replace it(replacedChars)

public void replaceWords() throws IOException{

      char[] charsToReplace = {'a','b','e','o','i'};
      char[] replacedChars = {'4','6','3','0','1'};
      
      replacedChars = charsToReplace;
      
      BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile));
      BufferedReader reader = new BufferedReader(new FileReader(inputFile));

      String line;
                
        for(int loopList=0; (line = reader.readLine()) !=null; loopList++)
        {
  .......................
        
        }
                
      reader.close();
      writer.close();
            
}
0
Comment
Question by:ahfish22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 92

Accepted Solution

by:
objects earned 1000 total points
ID: 12418571
// loop thru all chars to replace

for (int i=0; i<charsToReplace.length; i++)
{
   // replace character in line

   line = line.replace(charsToReplace[i], replacedChars[i]);
}
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question