【菜鸟求助】从一个txt向另一个txt打数据,用“,”分行

Gene1994 Gene1994 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
刚刚自学JAVA,对类型之间的转换还是不是很明白。。
想从
执行后效果是
import java.io.*;


public class SongList {

FileInputStream in = null;
FileOutputStream out = null;
int b = 0;
public static void main(String[] args) {
SongList s = new SongList();
s.go();

}
public void go(){
try{
in = new FileInputStream("c:/songlist.txt");
out = new FileOutputStream("C:/songlist(1).txt");
while ((b = in.read()) != -1){
String song = in.read()+"";
String[] s =song.split(",");
String k = s.toString();
byte[] m = k.getBytes();
out.write(m);
}
System.out.println("succeed!");
}catch(FileNotFoundException fe){
System.out.println("not found");
}catch (IOException ie) {
System.out.println("IOException");
}
}
}


这是我写的。。
结果是


想请教下 我是不是哪儿块儿理解出问题了。。就是类型转换不对造成这种结果了么。。
还有的话 就是如果songlist.txt里面如果有中文的话是不是需要用FileReader 和FileWriter? 谢谢!
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
Gene1994
Java SE 62,621 成员 307,251 内容