hi there;
<p>
i am reading a file and then write it to another new file. i have some problem when i want to check again some word.
<pre>
/* Copy a text file.
To use this program, specify the name
of the source file and the destination file.
For example, to copy a file called FIRST.TXT
to a file called SECOND.TXT, use the following
command line.
java CopyFile FIRST.TXT SECOND.TXT
*/
import java.io.*;
class CopyFile {
public static void main(String args[])
throws IOException
{
int i;
FileInputStream fin;
FileOutputStream fout;
try {
// open input file
try {
fin = new FileInputStream(args[0]);
} catch(FileNotFoundException e) {
System.out.println("Input File Not Found"
return;
}
// open output file
try {
fout = new FileOutputStream(args[1]);
} catch(FileNotFoundException e) {
System.out.println("Error Opening Output File"
return;
}
} catch(ArrayIndexOutOfBoundsException e) {
System.out.println("Usage: CopyFile From To"
return;
}
// Copy File
try {
do {
i = fin.read();
System.out.println("i = " + i);
if(i != -1) fout.write(i);
} while(i != -1);
} catch(IOException e) {
System.out.println("File Error"
}
fin.close();
fout.close();
}
}
</pre>
when i System.out.println("i = " + i); it return a integer for me, how if i want to check for word? for example,
<p>
if i = "tan" then call another function.....
<p>
i am reading a file and then write it to another new file. i have some problem when i want to check again some word.
<pre>
/* Copy a text file.
To use this program, specify the name
of the source file and the destination file.
For example, to copy a file called FIRST.TXT
to a file called SECOND.TXT, use the following
command line.
java CopyFile FIRST.TXT SECOND.TXT
*/
import java.io.*;
class CopyFile {
public static void main(String args[])
throws IOException
{
int i;
FileInputStream fin;
FileOutputStream fout;
try {
// open input file
try {
fin = new FileInputStream(args[0]);
} catch(FileNotFoundException e) {
System.out.println("Input File Not Found"
return;
}
// open output file
try {
fout = new FileOutputStream(args[1]);
} catch(FileNotFoundException e) {
System.out.println("Error Opening Output File"
return;
}
} catch(ArrayIndexOutOfBoundsException e) {
System.out.println("Usage: CopyFile From To"
return;
}
// Copy File
try {
do {
i = fin.read();
System.out.println("i = " + i);
if(i != -1) fout.write(i);
} while(i != -1);
} catch(IOException e) {
System.out.println("File Error"
}
fin.close();
fout.close();
}
}
</pre>
when i System.out.println("i = " + i); it return a integer for me, how if i want to check for word? for example,
<p>
if i = "tan" then call another function.....