Hi,
I wrote the following code.
The dis object reads the text from file. but it gives the problem while displaying on screen. The following line doesnt display the contents read in buffer 'aoBuffer'.
System.out.println(aoBuffer.toString());
Can anyone help me to solve the problem??
import java.io.*;
public class File_read {
String record = null;
int recCount = 0;
public static void main(String args[]){
String filename = null;
byte aoBuffer[] = new byte[256];
System.out.println("Enter the file name \n");
try {
int record = 0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
filename = br.readLine();
File f = new File(filename.toString());
FileInputStream fis = new FileInputStream(f);
BufferedInputStream bis = new BufferedInputStream(fis);
DataInputStream dis = new DataInputStream(bis);
while(record != (-1)) {
record = dis.read(aoBuffer, 0, aoBuffer.length);
System.out.println(aoBuffer.toString());
System.out.println(record);
}
dis.close();
}
catch (IOException e) {
// catch io errors from FileInputStream or readLine()
System.out.println("Uh oh, got an IOException error!" + e.getMessage());
}
}
}
[ August 26, 2008: Message edited by: laxmikant sabane ]