作者TonyQ (骨头)
站内java
标题Re: [问题] 读档的疑问
时间Wed May 3 02:19:36 2006
※ 引述《VictorLeon (QQ" N)》之铭言:
: 最近才刚接触JAVA不久 想请教一下读档的问题
: 我现在想读取一个有固定格式的档案
: 比如说档案开头有2个INT类型的资讯 也就是占了8个Byte
: 之後就全是Float的内容 所以想把後面的东西读进float的阵列里
: 但是看了书中的介绍 也只教到一次读一个Byte阵列 或者读字元
: 从前用C++的时候 就可以使用Read(&data,sizeof(data))
: 能读进资料到所宣告的不同型态的变数里
: 换成在Java 有什麽比较快速的方法吗?
Scanner可以参考看看:)
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html
在确定资料型态的状况下可以透过各种型态的next方法来取得资料
ex.
nextFloat()
nextInt()
--
local
--
String temp="relax"; | Life just like programing
while(buringlife) String.forgot(temp); | to be right or wrong
while(sleeping) brain.setMemoryOut(); | need not to say
stack.push(life.running); | the complier will
stack.push(scouting.buck()); | answer your life
stack.push(bowling.pratice()); | Bone
everything
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.138.240.58