I have a file, I typed in that file abalfazl hossein, and It returns this:
8
hossein
It works fine but I have question:
public int length()
Returns the length of this string. The length is equal to the number of 16-bit Unicode characters in the string.
and
seek
public void seek(long pos)
throws IOException
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs. The offset may be set beyond the end of the file. Setting the offset beyond the end of the file does not change the file length. The file length will change only by writing after the offset has been set beyond the end of the file.
Parameters:
pos - the offset position, measured in bytes from the beginning of the file, at which to set the file pointer.
If pos is measured in bytes, Then every character in
JAVA is 2 bytes,Then for "abalfazl", It is 16.
Then How it works?
I used 8 in seek method.