laxmikant sabane

Greenhorn
+ Follow
since Jun 04, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by laxmikant sabane

Hi Norm,
Thanks for comment.
Thanks for your suggestion.
I got the answer in String API.
Thank you for your valuable help.
15 years ago
Hi,
thanks for reply.
I am trying to read a simple text file.
aoBuffer is the array of bytes having size 256.
When I try to display the output using System.out.println(), it gives the following output:

[B@addbf1
256
[B@42e816
256
[B@9304b1
-1
15 years ago
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 ]
15 years ago