• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

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

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic