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

Posted on 2004-10-26
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++)
Question by:ahfish22
    1 Comment
    LVL 92

    Accepted Solution

    // 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]);

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Suggested Solutions

    Title # Comments Views Activity
    has22 challenge 11 45
    Null Boolean Values? 3 28
    Fibonacci challenge 11 45
    array11 challenge 16 20
    For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    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…
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

    877 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now