已经对读取的文经过处理,现在想把它存入另一个一个文,应该用什么命令,请各位大侠帮忙! 会读怎么就不会写呢?其实是一样的,不就是吧Reader改为Writer吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 FileWriter fOut = null; try { fOut = new FileWriter(file); String fileContent = "文件内容"; fOut.write(fileContent); fOut.close(); fOut = null; } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch(IOException eIO) { eIO.printStackTrace(); } finally { if (null != fOut) { try { fOut.close(); } catch (IOException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } } } import java.io.*;import java.util.*;class p2 { public static void main(String[] args) { try { BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream("p1.java"))); DataOutputStream dos=new DataOutputStream(new FileOutputStream("pp.java")); String str;Object o; //while(br.ready()) while((str=br.readLine())!=null) { l.add(str); //System.out.println(str); } //ListIterator it=l.listIterator(); int i=1; while ((o=l.removeLast())!=null) { System.out.println((String)o); dos.writeBytes(i+" "+(String)o+"\n"); i++; } while(it.hasNext()) { System.out.println((String)it.next()); } while(it.hasPrevious()) { System.out.println((String)it.previous()); }*/ //System.out.println("Hello World!"); } catch (Exception e) { } }} 求解通过jacob调用Apabi问题 java indexof的问题 ■■■请教String截取问题■■■ 用什么技术实现联众,QQ游戏的风格界面? swt新手请教 哪里有linux下的jdk可以下载? 如果实现鼠标双键事件? 老是说class 类名 not found 如何取指定的一段字符串? 如何调用windows下的exe? 发现一个读取的问题,渴望指教! 请教一个关于java编码的问题!
try
{
fOut = new FileWriter(file);
String fileContent = "文件内容";
fOut.write(fileContent);
fOut.close();
fOut = null;
}
catch (FileNotFoundException e1)
{
e1.printStackTrace();
}
catch(IOException eIO)
{
eIO.printStackTrace();
}
finally
{
if (null != fOut)
{
try {
fOut.close();
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
}
}
import java.util.*;class p2
{
public static void main(String[] args)
{
try
{
BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream("p1.java")));
DataOutputStream dos=new DataOutputStream(new FileOutputStream("pp.java"));
String str;Object o;
//while(br.ready())
while((str=br.readLine())!=null)
{
l.add(str);
//System.out.println(str);
}
//ListIterator it=l.listIterator();
int i=1;
while ((o=l.removeLast())!=null)
{
System.out.println((String)o);
dos.writeBytes(i+" "+(String)o+"\n");
i++;
}
while(it.hasNext())
{
System.out.println((String)it.next());
}
while(it.hasPrevious())
{
System.out.println((String)it.previous());
}
*/
//System.out.println("Hello World!");
}
catch (Exception e)
{
} }
}