Could you help me to correct and combine two code in the following?
Thank you very much. Then sent it to me with [EMAIL PROTECTED]
The requirment is that :
In Task 2, Design three java threads. Each thread usess an input dialogue
box to provide user interface for search English word. I then reports
whether or not the typed words is part of the text file in the program of
task 1. The thread is terminated once a user type the word "finish".
----------------------------------------------------------------------------
--------------
Task 1: (There have a input file)
-----------------------------------------------------------------------
import java.util.StringTokenizer;
import java.io.*;
public class WordReverse {
public static void main(String[] args) throws IOException {
FileReader file = new FileReader("input.txt");
BufferedReader buff = new BufferedReader(file);
FileWriter out = new FileWriter("out.txt");
String line = buff.readLine();
String outLine="";
while( line != null || line == ""){
StringTokenizer str = new StringTokenizer(line);
while (str.hasMoreTokens()) {
String tokenHelp = str.nextToken();
outLine = tokenHelp + " " +outLine;
}
System.out.println(outLine);
outLine+="\r\n";
out.write(outLine);
outLine="";
line = buff.readLine();
}
out.close();
}
}
============================================================================
======================
Task 2:(It is incompletely):
-----------------------------------
import javax.swing.JOptionPane;
import java.io.*;
import java.lang.*;
public class WordSearch
{
file://-----------------------variable-----------------------
public static String
file://------------------search single word (method)----------------------
public void SearchBook()
{
String s2=JOptionPane.showInputDialog("input search word:");
j=0;
k=0;
System.outprintln("The word is")
;
for(j=1;j<word.length-1;j++)
{
if (word[j].equals(s2))
{
System.out.println(word[j]);
k++;
}
}
System.out.println("There have "+k+" word(s)");
}
file://--search word that have more than seven and less than thirteen
(method)-------
file://---------------main---------------------------------
public static void main(String args[])throws Exception
{
FileReader file = new Filereader("input.txt")
BufferedReader buff = new BufferedReader(file);
String line = buff.readline();
String outLine="";
while(line !+null
Book jbook = new Book();
String s1;
int num;
int control;
control = 0
while (control == 0)
{s1 =JOptionPane.showInputDialog("1.Search word record \n
2.Search word that have more than seven and less than thirteen \n
3.Close the windows \n Please input the task number:")
num = Integer.parseInt(s1);
i = word.length;
switch(num)
file://------------------case 1(Search word record)---------------------
case 1:
{
for(i=1;i<word.length;i++)
{if (word[i].equals()break;}
System.out.println("It exist in the input file!");
break;
}
file://------case 2(Search word that have more than seven and less than
thirteen)-----
case 2:
for(i=1;i,word.length;i++)
{if
System.out.println("It exist in the input file!");
file://------------------case 3(Close the Windows)-----------------------
case 3:
file://-----------------------------------------------
}
String sr=JOptionPane.showInputDiolog("Repeat? (Yes=0 / No=1)";
control=Integer.parseInt(sr);
}
System.exit(0);
}