Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help!!!how can fetch the content of a file to a String?  RSS feed

 
Daniel Washington
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RandomAccessFile rowDataFile=new RandomAccessFile("cards.txt","rw");
byte byte1[]=new byte[(int)rowDataFile.length()];
rowDataFile.readFully(byte1,0,(int)rowDataFile.length());
System.out.println(byte1);
....
always print: [B@1fc2fb
but the "Cards.txt" is indeed have some content!
please help me!!!thx
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are trying to print the byte array object instead of printing the contents of the byte array. That's why it is printing the object reference code.
Try this instead
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!