急 急 急 ,请 教 斑 竹与 大 虾 们 ,输 出 到 文 件 的 可 读 性 问 题 那 么 将 (new FileWriter("myfile",true)).write ((int)xxx)改 成 (new FileWriter("myfile",true)).write ((char)xxx)就 行 了 ? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 试试:(new FileWriter("myfile",true)).write (String xxx,0,xxx.length()); 斑 竹 ,我 试 了 试 这 段 写 法 似 乎 也 没 用 .fw.write(new Integer(i).toString(),0,500);其 中 fw=new FileWriter();i=int;另 外 ,我 还 想 问 ,在 一 段 程 序 中 我 写 了 上 面 一 句 ,则 只 打 印 了 第 一 个 结 果 .若 没 有 以 上 这 行 ,则 输 出 结 果 正 常 ,这 又 是 为 何 ?import java.io.*;public class Four2 { int count=0; void go(){ try { FileWriter fw=new FileWriter("myfile",true); //以 下 这 段 用 于 打 印 11111至 44444间 各 位 数 只 能 为 1至 4的 数 . for(int i=11111;i<44444;i++){ int i0=(int)Math.floor(i/10000); int i1=(int)Math.floor((i-i0*10000)/1000); int i2=(int)Math.floor((i—i0*10000-i1*1000)/100); int i3=(int)Math.floor((i-i0*10000-i1*1000-i2*100)/10); int i4=i-i0*10000-i1*1000-i2*100-i3*10; if(i1<1||i1>4)continue; if(i2<1||i2>4)continue; if(i3<1||i3>4)continue; if(i4<1||i4>4)continue; System.out.print(i+" ");attention: fw.write(new Integer(i).toString(),0,500); fw.flush(); //fw.close(); count++; if(count>256)break; }}catch (IOException e){} catch (StringIndexOutOfBoundsException e){} } public static void main(String args[]){ Four2 four=new Four2(); four.go(); }} fw.write(new Integer(i).toString(),0,500);估计这一句有exeption抛出在catch (StringIndexOutOfBoundsException e){} }后面加上catch(Exception e) { System.out.println("OOPS!Exception caught!"); e.printStackTrace();}就知道事什么原因了 Shania(魔鬼身材)说的有道理,肯定是你的fw.write(new Integer(i).toString(),0,500);出问题了,可以在后面的catch中加入打印出错代码。 类或函数上面的叫什么 将当前面板生成图片问题 一道笔试题(java) 关于线程的问题!急等! 初学JAVA郁闷 快来抢分啦 为什么我这个问题贴发了这么多一个回复都没有呢?CSDN上的高手哪去了啊? 请指点 送分题目 (很急)谢谢!我想问一下调用一个对话框的命令语句,比方说我已建立了一个Applet2,接下来该如何在Applet中能点击一个按钮来打开这个Apple spring配置事务没生效 求购java的反编译器,要求反编译效果好的-急! 求教关于范围的问题?
(new FileWriter("myfile",true)).write (String xxx,0,xxx.length());
fw.write(new Integer(i).toString(),0,500);
其 中 fw=new FileWriter();i=int;另 外 ,我 还 想 问 ,在 一 段 程 序 中 我 写 了 上 面 一 句 ,则 只 打 印 了 第 一 个 结 果 .若 没 有 以 上 这 行 ,则 输 出 结 果 正 常 ,这 又 是 为 何 ?
import java.io.*;public class Four2 { int count=0;
void go(){
try { FileWriter fw=new FileWriter("myfile",true);
//以 下 这 段 用 于 打 印 11111至 44444间 各 位 数 只 能 为 1至 4的 数 .
for(int i=11111;i<44444;i++){
int i0=(int)Math.floor(i/10000);
int i1=(int)Math.floor((i-i0*10000)/1000);
int i2=(int)Math.floor((i—i0*10000-i1*1000)/100);
int i3=(int)Math.floor((i-i0*10000-i1*1000-i2*100)/10);
int i4=i-i0*10000-i1*1000-i2*100-i3*10;
if(i1<1||i1>4)continue;
if(i2<1||i2>4)continue;
if(i3<1||i3>4)continue;
if(i4<1||i4>4)continue;
System.out.print(i+" ");
attention: fw.write(new Integer(i).toString(),0,500);
fw.flush();
//fw.close();
count++;
if(count>256)break;
}
}catch (IOException e){}
catch (StringIndexOutOfBoundsException e){}
} public static void main(String args[]){ Four2 four=new Four2();
four.go();
}
}
估计这一句有exeption抛出
在
catch (StringIndexOutOfBoundsException e){}
}
后面加上
catch(Exception e) {
System.out.println("OOPS!Exception caught!");
e.printStackTrace();
}就知道事什么原因了
出问题了,可以在后面的catch中加入打印出错代码。