http://gaia.ecs.csus.../dictionary.txt
import java.util.Scanner;
import java.io.*;
public class Lab12
{
public static void main(String[] args)
{
Scanner in_obj = null;
PrintWriter out_obj = null;
boolean yes;
try
{
in_obj = new Scanner(new FileInputStream("dictionary.txt"));
out_obj = new PrintWriter(new FileOutputStream("pals.txt"));
}
catch (FileNotFoundException e)
{
System.out.println("Can't read/write files in folder.");
System.exit(0);
}
while (in_obj.hasNextLine())
{
String line_read = in_obj.nextLine();
char my_array[] = line_read.toCharArray();
for (int L = 0, R = (my_array.length - 1); L < (my_array.length / 2); L++, R--)
{
if (my_array[L] != my_array[R])
{
break;
}
if (L == my_array.length / 2 - 1)
{
out_obj.println("Hello! " + line_read);
break;
}
}
}
out_obj.println();
out_obj.print("Bye, bye!");
in_obj.close();
out_obj.close();
}
}


Sign In
Create Account


Back to top









