-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.4.0
-
x86
-
solaris_2.5.1
Name: gm110360 Date: 02/09/2002
FULL PRODUCT VERSION :
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)
also
in java 1.3.1_1
FULL OPERATING SYSTEM VERSION :
Microsoft Windows XP [Version 5.1.2600]
ADDITIONAL OPERATING SYSTEMS :
Also tested in Linux and Windows 98
A DESCRIPTION OF THE PROBLEM :
When I write a small byte array which contain a chinese
character "me" code, A7 DA,
the out will be in UTF-8 format but if there is no this
code, the format is ok
e.g.
if the byte[] is "A7 DA A4 A4 A7 D8",
the output will become other....
I mean when write out it in a FileOutputStream,
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.
2.
3.
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
FileInputStream inputFileStream = new FileInputStream(inputFile);
if (inputFileStream == null)
return false;
FileChannel fileChannel = inputFileStream.getChannel();
fileSize = (int) fileChannel.size();
MappedByteBuffer tempInputByteBuffer = fileChannel.map
FileChannel.MapMode.READ_ONLY, 0, fileSize);
fileChannel.close();
FileOutputStream outputDatabaseStream = new FileOutputStream(pdbFile);
fileChannel = outputDatabaseStream.getChannel();
ByteBuffer writeOutByteBuffer = ByteBuffer.allocate(fileSize);
int count = 0;
for (int i = 0; i < fileSize; i++)
{
byte b = inputByteBuffer.get();
if (b != '\r' && b != '\n')
{
count++;
writeOutByteBuffer.put(b);
}
}
writeOutByteBuffer.position(0);
writeOutByteBuffer.limit(count);
fileChannel.write(writeOutByteBuffer);
fileChannel.close();
return true;
---------- END SOURCE ----------
(Review ID: 138627)
======================================================================