将写入的内容在文本文件中换行 请各位帮我一下,怎样用FileWriter, 将我们的字符串写在文本文件中,在文本文件中进行换行呢?我不知道怎样将写入的内容在文本文件中换行? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 package studypack;import java.io.*;public class witeTxt { /** * @param args */ public static void main(String[] args) { File file=new File("c:\\out.txt"); try { FileWriter out=new FileWriter(file); String str1="www.csdn.com"; String str2="www.sina.com"; String str3=new StringBuffer().append("\"").append(str1).append("\"").toString(); String str4=new StringBuffer().append("\"").append(str2).append("\"").toString(); out.write(str3); out.write(32); out.write(str4); out.close(); } catch(Exception e) { e.getMessage(); } try { FileReader in=new FileReader(file); char buf[]=new char[1024]; int len=in.read(buf); System.out.println(new String(buf,0,len)); } catch(Exception e) { e.getMessage(); } }}我现在要想在out.txt中,将写入是内容变成这样:www.csdn.comwww.sina.com两行;怎么做啊? 把这句out.write(32);改成out.write("\r\n"); 53.字符串的回车String s="hi newman"+"\r\n";加入了回车换行 新手求教:判断为一个数是否为五位数时,输入五位数,也提示重新输入? 我想用java实现就像记事本“打开”功能 要如何实现呢? 关于设置classpath java 如何得到本地窗口的大小 刚学JAVA新手问题-动态数组-文件读写-文件排序 用wsdd来部署带*.jar包的服务(类)报错! zai win2000 profession zhong bu neng qie huan shu ru fa ? 怎样获一个变量的数据类型 java到底能干什么? 请问高手:拖动表格的事件怎样监听? 求算法复杂度。 请问有没有人用过命令行增强工具?
import java.io.*;
public class witeTxt
{ /**
* @param args
*/
public static void main(String[] args)
{
File file=new File("c:\\out.txt");
try
{
FileWriter out=new FileWriter(file);
String str1="www.csdn.com";
String str2="www.sina.com";
String str3=new StringBuffer().append("\"").append(str1).append("\"").toString();
String str4=new StringBuffer().append("\"").append(str2).append("\"").toString();
out.write(str3);
out.write(32);
out.write(str4);
out.close();
}
catch(Exception e)
{
e.getMessage();
}
try
{
FileReader in=new FileReader(file);
char buf[]=new char[1024];
int len=in.read(buf);
System.out.println(new String(buf,0,len));
}
catch(Exception e)
{
e.getMessage();
}
}}
我现在要想在out.txt中,
将写入是内容变成这样:
www.csdn.com
www.sina.com
两行;怎么做啊?
String s="hi newman"+"\r\n";加入了回车换行