作者LPH66 (-858993460)
看板java
标题Re: [问题] Eclipse/jar档 有点怪的Bug
时间Sat Nov 27 00:00:07 2010
※ 引述《xephon ()》之铭言:
: 最近遇到了一个有点怪的Bug,希望各位高手能指点一下
: 问题:Eclipse平台上直接执行没错误
: 转成Jar档之後执行出错
: 状况大概是这样,我的程式要存档一些int到txt中
: 然後程式重启时可以读档回来
: 以下皆是INT
: 只是排版没有存空白
: Case 1(Eclipse): ↓↓
: 存入txt→ 3,4,5,1,2,32767 , 40,80,50,135,60,230,75,350, ...
: 放入A阵列 放入B阵列
: txt读回→ [3,4,5,1,2,32767], [40,80,50,135,60,230,75,350, ... ]
: Case 2(Jar):
: 存入txt→ 3,4,5,1,2,32767 , 40,80,50,135,60,230,75,350, ...
: 放入A阵列 放入B阵列
: txt读回→ [3,4,5,1,2,32767], [40,80,50, 63,60, 63,75, 63, ... ]
: 错 错 错
: 这是哪方面的问题呢?
: 发现只要超过100的部分都会变成63 (3F)
: 但是32767这里又没有问题
: 是转成Jar档时的问题还是说程式本身有bug?
: 但是在Eclipse环境下执行又很正常,请求一些指点...
还是回文好了
你是否有用 String.getByte() ?
因为会发生一百多变成 63 的情形很可能是不知不觉中做了转码
(由於转码时没有字的会变成 '?' 正是 63)
而会转码的函式就我所知只有 String.getByte()
不过 32767 没事就很谜了...
--
'You've sort of made up for it tonight,' said Harry. 'Getting the
sword. Finishing the Horcrux. Saving my life.'
'That makes me sound a lot cooler then I was,' Ron mumbled.
'Stuff like that always sounds cooler then it really was,' said
Harry. 'I've been trying to tell you that for years.'
-- Harry Potter and the Deathly Hollows, P.308
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.30.81
1F:推 xephon:多谢你的意见 不过我没用getByte 另外Eclipse上是对的@@ 11/27 11:52
2F:→ xephon:用getByte的话应该两边都会错才是 11/27 11:53