Question: java help: Seuss.java import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Scanner; public class Seuss { public static void main(String args[]) throws FileNotFoundException { LinkedSet set=new
java help:

Seuss.java import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
public class Seuss {
public static void main(String args[]) throws FileNotFoundException
{
LinkedSet
File infile = new File("./src./greenEggs.txt");
File outfile = new File("words.txt");
String word=null;
PrintWriter out=null;
Scanner read = null;
try {
read = new Scanner(infile);
out=new PrintWriter(outfile);
while(read.hasNext())
{
word=remmovePunc(read.next());
set.add(word);
}
System.out.print(set);
while(true)
{
word=set.remove();
if(word==null)
{
break;
}
out.write(word+" ");
out.flush();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static String remmovePunc(String s)
{
String str="";
String a=s.toLowerCase();
for(int i=0;i { if (Character.isLetter(a.charAt(i))){ str=str+a.charAt(i); } } return str; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
