Topic: 大家来帮帮忙,关于将文件数字读到数组的问题. |
Print this page |
1.大家来帮帮忙,关于将文件数字读到数组的问题. | Copy to clipboard |
Posted by: sss6586576 Posted on: 2004-12-19 10:21 import java.io.*; public class ccc { File f; FileInputStream f1; DataInputStream f2; int b[]; int i=0; public ccc() { b=new int[5]; f=new File("G:\\","11.txt"); try{ f1=new FileInputStream; f2=new DataInputStream(f1); while((b[i]=f2.readInt()-'0')!=-1) { System.out.println(b[i]); i++; } } catch(IOException e) { System.out.println("error"+e); } } public static void main(String[] args) throws FileNotFoundException { ccc ddd=new ccc(); } } 如何将50 12 14 78 读到整型数组中.郁闷ing!! 读个位数字可以,但读十位的就不行了.大家帮帮忙吧. |
2.Re:大家来帮帮忙,关于将文件数字读到数组的问题. [Re: sss6586576] | Copy to clipboard |
Posted by: doway Posted on: 2004-12-27 22:02 DataInputStream不是用来读取文本文件的,读取文本文件应该使用BufferedReader,读取整行,然后再分析字符串。 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |