由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - help about bitstream writer
相关主题
question on stream write怎麼得到字符串中的raw bytes?
一个socket相关的问题How to parse the bytes[]
关于char和int的问题Core Java2 Notes (6)
convert array to blob[转载] Actually let me rephrase my question
how to read from a non-return socket stream?help! BufferedImage
Object stream & serilization有啥用处?问高手:数字签名
问个很简单的问题?How to know the size of a file in a prog
怎样吧byte[]变成java.security.Key?how to multicast objects to clients in java?
相关话题的讨论汇总
话题: bitstream话题: 2147483648话题: stream话题: writer话题: any
进入Java版参与讨论
1 (共1页)
z********i
发帖数: 60
1
Using io.Outputstream, I need to write some 32 bit integer to the
stream. any value is fine except -2147483648 and 2147483648. I tried
to just mask 32 bits and cut them in bytes. The bitstream is just
ended with them without any warning.
Thank you for taking time.
m******t
发帖数: 2416
2

Ever occurred to you 2147483648 is not a valid int?

【在 z********i 的大作中提到】
: Using io.Outputstream, I need to write some 32 bit integer to the
: stream. any value is fine except -2147483648 and 2147483648. I tried
: to just mask 32 bits and cut them in bytes. The bitstream is just
: ended with them without any warning.
: Thank you for taking time.

z********i
发帖数: 60
3

it is 0x80000000. do you think it is overflow?

【在 m******t 的大作中提到】
:
: Ever occurred to you 2147483648 is not a valid int?

m******t
发帖数: 2416
4

JLS 4.2.1: "For int, from -2147483648 to 2147483647, inclusive".

【在 z********i 的大作中提到】
:
: it is 0x80000000. do you think it is overflow?

z********i
发帖数: 60
5
but how can I write 255 for in a byte. Java has no unsigned int, unsigned
byte..right? Thanks

【在 m******t 的大作中提到】
:
: JLS 4.2.1: "For int, from -2147483648 to 2147483647, inclusive".

m******t
发帖数: 2416
6

If you are the only one reading/writing this stream, just use
ObjectOutputStream.writeLong().

【在 z********i 的大作中提到】
: but how can I write 255 for in a byte. Java has no unsigned int, unsigned
: byte..right? Thanks

z********i
发帖数: 60
7
Since I need to write a serial bits into a stream, I changed to use
DataOutputStream.writeChar(int v). for char, it is valid from 0 to 0xffff, for
my program, the value of 65277 (0xfefd) works fine, but 65278 cannot write
correctly. Any idea?

【在 m******t 的大作中提到】
:
: If you are the only one reading/writing this stream, just use
: ObjectOutputStream.writeLong().

m******t
发帖数: 2416
8

for
Not sure, maybe it has to do with unicode.
I'm still not sure I understand your requirement. Does this stream have to
conform to a certain standard? Is there any other code that will directly
access this stream? etc. These are all the questions need to be answered
before you can decide how you want to do this.

【在 z********i 的大作中提到】
: Since I need to write a serial bits into a stream, I changed to use
: DataOutputStream.writeChar(int v). for char, it is valid from 0 to 0xffff, for
: my program, the value of 65277 (0xfefd) works fine, but 65278 cannot write
: correctly. Any idea?

1 (共1页)
进入Java版参与讨论
相关主题
how to multicast objects to clients in java?how to read from a non-return socket stream?
How to compute round-trip time to webserObject stream & serilization有啥用处?
socket and simple web browser问个很简单的问题?
self-modifying code?怎样吧byte[]变成java.security.Key?
question on stream write怎麼得到字符串中的raw bytes?
一个socket相关的问题How to parse the bytes[]
关于char和int的问题Core Java2 Notes (6)
convert array to blob[转载] Actually let me rephrase my question
相关话题的讨论汇总
话题: bitstream话题: 2147483648话题: stream话题: writer话题: any