在线等,比较急!!!我用java版的结巴分词写了一段代码,怎样将它输出到指定的txt文件中?
importjava.io.BufferedReader;importjava.io.BufferedWriter;importjava.io.File;importja...
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import com.huaban.analysis.jieba.JiebaSegmenter;
public class Test {
public static void main(String[] args) throws IOException {
JiebaSegmenter segmenter = new JiebaSegmenter();
File file = new File("F:\\Test.java");//Text文件
BufferedReader br = new BufferedReader(new FileReader(file));//构造一个BufferedReader类来读取文件
String s = null;
while((s = br.readLine())!=null)//使用readLine方法,一次读一行
// String text = "我实在是无语了";
System.out.println(segmenter.sentenceProcess(s));
BufferedWriter out = new BufferedWriter(new FileWriter("F:\\out.txt"));
}
}
解决了 不用了 谢谢 展开
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import com.huaban.analysis.jieba.JiebaSegmenter;
public class Test {
public static void main(String[] args) throws IOException {
JiebaSegmenter segmenter = new JiebaSegmenter();
File file = new File("F:\\Test.java");//Text文件
BufferedReader br = new BufferedReader(new FileReader(file));//构造一个BufferedReader类来读取文件
String s = null;
while((s = br.readLine())!=null)//使用readLine方法,一次读一行
// String text = "我实在是无语了";
System.out.println(segmenter.sentenceProcess(s));
BufferedWriter out = new BufferedWriter(new FileWriter("F:\\out.txt"));
}
}
解决了 不用了 谢谢 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询