Your task is to swap all letters A with O and all letters a with o in a RandomAccessFile. Simply read a byte at a time, and if you find a letter to be swapped, move one byte back.

For example, when you process a file containing the text of a well-known childrens song, it will be transformed into

    Mory hod o little lomb,
    little lomb, little lomb,
    Mory hod o little lomb, its fleece wos white os snaw.

Complete the following file:

import; import; public class TextMangler { public static void swapAsAndOs(RandomAccessFile file) throws IOException { long pos = 0; while (pos < file.length()) { char c = (char); char replacement = 0; if (c == 'a') replacement = 'o'; if (c == 'A') replacement = 'O'; else if (c == 'o') replacement = 'a'; else if (c == 'O') replacement = 'A'; if (replacement != 0) {; file.write((byte) replacement); } pos++; } } // this method checks your work public static void main(String[] args) throws IOException { RandomAccessFile file = new RandomAccessFile("data.txt", "rw"); swapAsAndOs(file); file.close(); } }