java怎么读写文件啊????急!!!!!!!!!!!! http://www.csdn.net/develop/read_article.asp?id=17710 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用FileInputStream和FileOutStream两个类来实现读写 import java.io.*; class showfile{ public static void main(String args[]) throws IOException{ int i; FileInputStream fin; FileOutputStream fout; PrintWriter pw=new PrintWriter(System.out,true); try{ fin=new FileInputStream("jct.txt"); }catch(FileNotFoundException exc){ pw.println("File not found"); return; } try{ fout=new FileOutputStream("test.txt"); }catch(FileNotFoundException exc){ pw.println("file not found"); return; } do{ i=fin.read(); if(i!=-1) fout.write(i); }while(i!=-1); fin.close(); fout.close(); } } 这是拷贝文件的java 原程序,希望对你有帮助 第一,你要读什么文件,binary文件还是text文件。第二,你要读的文件是在class folder里,还是project folder里。如果你用Jbuilder,就是说你要读的文件是在classes目录下面,还是在project跟目录下面。 Thinking in Java 里第十章就是讲文件的读写的,全都是这方面的例子! http://expert.csdn.net/Expert/topic/2052/2052241.xml?temp=.8718225 很简单的问题,学一学Java I/O 就OK 求解字节与字符问题 怎么实现两个list表的复制 菜鸟提问:Hello world程序在eclipse下能正确的运行但是在DOS下就是总出错, debug时,Action@1a05c93 这个@后面的是什么? 大家帮我看看这个代码片段的问题是什么?在考哪个知识点 有谁想过,nba常规赛的赛程表编排的算法? 初学求助啊!!!!!!!帮帮忙 一个读写文件的异常 java怎样实现屏幕抓图,图象压缩??? jna调用c的dll中函数原型的问题,在线等。 简单的聊天工具的一些问题 <java编程思想II>(非候老先生版)谁有这本书?高分求书!有的请帮帮忙!
class showfile{
public static void main(String args[])
throws IOException{
int i;
FileInputStream fin;
FileOutputStream fout;
PrintWriter pw=new PrintWriter(System.out,true);
try{
fin=new FileInputStream("jct.txt");
}catch(FileNotFoundException exc){
pw.println("File not found");
return;
}
try{
fout=new FileOutputStream("test.txt");
}catch(FileNotFoundException exc){
pw.println("file not found");
return;
}
do{
i=fin.read();
if(i!=-1) fout.write(i);
}while(i!=-1);
fin.close();
fout.close();
}
}
这是拷贝文件的java 原程序,希望对你有帮助
第二,你要读的文件是在class folder里,还是project folder里。如果你用Jbuilder,就是说你要读的文件是在classes目录下面,还是在project跟目录下面。