File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes Reading two text file using streamtokenizer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Reading two text file using streamtokenizer " Watch "Reading two text file using streamtokenizer " New topic
Author

Reading two text file using streamtokenizer

Pauline Pauline
Greenhorn

Joined: Apr 12, 2008
Posts: 1
Hi all,
i have written a program to read a text file using streamtokenizer but there's some program when i compile and it says no source file but i have already put the text file into the folder together with the java program .Can anyone help me ?
Here's the program :
import java.io.*;
import java.util.*;

class TokenTest {

public static void main (String[] args) {
TokenTest tt = new TokenTest();
tt.dbTest();
}

void dbTest() {

DataInputStream dis = null;
String dbRecord = null;
String dbBase =null;

try {

File f = new File("studentScore1.txt");
File a = new File("studentScore2.txt");
FileInputStream fis = new FileInputStream(f);
FileInputStream fin = new FileInputStream(a);
BufferedInputStream bis = new BufferedInputStream(fis);
BufferedInputStream bia = new BufferedInputStream(fin);

dis = new DataInputStream(bis);
eis = new DataInputStream(bia);


// read the first record of the database
while ( (dbRecord = dis.readLine()) != null) {


StringTokenizer st = new StringTokenizer(dbRecord, "");
String studentID = st.nextToken();
String score = st.nextToken();

System.out.println("StudentIDScore" );
System.out.println(studentID+score);

}
while ( (dbBase= eis.readLine()) != null) {


StringTokenizer st = new StringTokenizer(dbBase, "");
String studentID = st.nextToken();
String score = st.nextToken();

System.out.println("StudentIDScore" );
System.out.println(studentID+score);

}






} catch (IOException e) {
// catch io errors from FileInputStream or readLine()
System.out.println("Uh oh, got an IOException error: " + e.getMessage());

} finally {
// if the file opened okay, make sure we close it
if (dis != null) {
try {
dis.close();
} catch (IOException e) {
System.out.println("IOException error trying to close the file: " +
e.getMessage());
}

} // end if

} // end finally

} // end dbTest

} // end class
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

The problem you have mentioned is definetly not with your code.
Can you tell what command you are using to compile and what exactly is the error you are getting.
Make sure your java file has an extension .java and you specify this in calling javac


apigee, a better way to API!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading two text file using streamtokenizer