JAVA文件读写例题实现过程解析
练习
有这样的一个words数组,数组中每个字符串的格式为“词性:单词”
String[]words={"verb:eat","verb:drink","verb:sleep","verb:play","noun:rice","noun:meat","noun:hand","noun:hair"};
根据单词性质动词verb全部存入verb.txt文件中
根据单词性质名词noun全部存入noun.txt文件中
packagereadandwrite;
/*1.有这样的一个words数组,数组中每个字符串的格式为“词性:单词”
String[]words={"verb:eat","verb:drink","verb:sleep","verb:play","noun:rice","noun:meat","noun:hand","noun:hair"};
根据单词性质动词verb全部存入verb.txt文件中
根据单词性质名词noun全部存入noun.txt文件中
*/
importjava.io.*;
publicclassFileReadAndWrite{
publicstaticvoidmain(Stringargs[])throwsIOException{
//WORDS数组
String[]words={"verb:eat","verb:drink","verb:sleep","verb:play","noun:rice","noun:meat","noun:hand","noun:hair"};
FileOutputStreamoutFile1=newFileOutputStream("verb.txt");
FileOutputStreamoutFile2=newFileOutputStream("noun.txt");
OutputStreamout1=newBufferedOutputStream(outFile1);
OutputStreamout2=newBufferedOutputStream(outFile2);
for(inti=0;i
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短