• Post Reply Bookmark Topic Watch Topic
  • New Topic

file.length RandomAccessFile  RSS feed

 
Arun kumar Maalik
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.io.*;
public class Files {
RandomAccessFile file=null;
public static void main(String []args){
file=RandomAccessFile("work.txt");
file.writeInt(85);
file.writeChar('V');
System.out.println(file.length());
}
}

Helo frnd in the above code file.length is returning 10 as a length although i have entered data in that file only 6(int 4,char 2) and i know that length function mesure the length of file in byte. pls specify the Answer so that i get it.

with regard

Arun kumar maalik
 
Mike Noel
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at the file in a binary file editor to see what characters got written? That might give you a clue as to what's going on.

_M_
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!