
import java.lang.String;
import java.io.*;
import java.util.*;
public class Vowels{
public static void main(String args[])throws IOException{
File aa = new File("C:\\Temp1\\1.txt");
File bb = new File("C:\\Temp1\\2.txt");
File cc = new File("C:\\Temp1\\3.txt");
String text=Vowels.getContents(aa);
System.out.println(text);
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
if (c=='a' || c=='e' || c=='i' || c=='o' || c=='u') {
Vowels.setContents(bb, c);
}
else
if(c != 'a' || c != 'e' || c != 'i' || c != 'o' || c != 'u' || c != ' ')
{
Vowels.setContents(cc, c);
}
}
}
static public String getContents(File aFile) {
StringBuilder contents = new StringBuilder();
try {
BufferedReader input = new BufferedReader(new FileReader(aFile));
try {
String line = null;
while (( line = input.readLine()) != null){
contents.append(line);
contents.append(System.getProperty("line.separator"));
}
}
finally {
input.close();
}
}
catch (IOException ex){
ex.printStackTrace();
}
return contents.toString();
}
static public void setContents(File aFile, char c)
throws FileNotFoundException, IOException {
if (aFile == null) {
throw new IllegalArgumentException("File should not be null.");
}
if (!aFile.exists()) {
throw new FileNotFoundException ("File does not exist: " + aFile);
}
if (!aFile.isFile()) {
throw new IllegalArgumentException("Should not be a directory: " + aFile);
}
if (!aFile.canWrite()) {
throw new IllegalArgumentException("File cannot be written: " + aFile);
}
Writer output = new BufferedWriter(new FileWriter(aFile));
try {
output.append(c);
}
finally {
output.close();
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.