Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writeChras() problem

Status
Not open for further replies.

satellite03

IS-IT--Management
Dec 26, 2003
248
IN
Code:
import java.io.*;

class RAFtest
{
public static void main(String args[]) throws IOException
{
RandomAccessFile  f  = new  RandomAccessFile("c:\\abc.txt","rw");
BufferedReader abc = new BufferedReader(new FileReader("c:\\def.txt"));
String s = abc.readLine();
f.writeChars(s);
}
}


def.txt
_______
abcd



output in abc.txt
__________________
a b c d // note the gaps in between chars


why there are gaps ? if i usued writeBytes() there would have been no gaps.
how those gaps have been created in the output?


 
>writeChars() writes the letters in Unicode instead of Ascii, so it takes two bytes per character.

can you tell the mechanism how it is written ?

is it like, first it will read 'a' then write 'a' and put a gap ? right ?

things are messy here.i dont understand the way it is processing.


thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top