关于文件保存和打开的问题(急急急) FileOutputStream 没有用过,能不能详细介绍用法并且举例呢,谢谢,在线等待中 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 FileOutputStream fos = new FileOutputStream("d:/newFile");String str = "aaaaaaaaaa";fos.write(str.getBytes());fos.flush();fos.close(); class SavesListener implements ActionListener{ public void actionPerformed(ActionEvent e){ JFileChooser c = new JFileChooser(); FileOutputStream fos = new FileOutputStream(c.getCurrentDirectory().toString()); String str = new String(); str = "aaa"; fos.wirte(str.getBytes()); fos.flush(); fos.close(); } }那我这么写对吗,提示有错误啊,请帮忙看看哪里错了,谢谢 FileOutputStream fos = new FileOutputStream("d:/newFile");String str = "aaaaaaaaaa";fos.write(str.getBytes());fos.flush();fos.close();用上面这些代码的时候,提示cannot resolve symbol,是fos.write(str.getBytes());这句,是不是没有import什么东西,我import java.io.*;,还需要import 什么吗? TO: mymoto(忽忽) ,用 FileOutputStream 类// 读文件 FileInputStream fin =new FileInputStream("c:\\text.txt");byte rec[] = new byte[1024];fin.read(rec);fin.close() ;outstr = (new String(rec)).trim() ;int i = Integer.parseInt(outstr);// 文件读完,并将数据要 i 返回 // 将 i 加一,然后写文件i = i + 1;outstr = String.valueOf(i);FileOutputStream fout1 =new FileOutputStream("c:\\text.txt");fout1.write(outstr.getBytes());fout1.close();// 文件写完 谢谢: 9742wsx(aa) ,有一点不明白,其中i是做什么用的,outstr是String类型吗?做什么用的,还有,c:\\text.txt为什么是\\而不是\,请指点 File selectFile=c.getSelectedFile();BufferedWriter writeFile=new BufferedWriter(new FileWriter(selectFile)); //使用缓冲写入文件 String str=texts.getText();writeFile.write(str.nextToken()); writeFile.flush();writeFile.close(); 兄弟,多看点书吧不过我也是菜鸟\在java中转意字符,和C语言一样的\t代表tab,\n\r\\代表\上面的例子是个计数器的用处啊,outstr当然是String了 to:小舟提示cannot resolve symbolsymbol: method nextToken()location: class.java.lang.StringwriteFile.write(str.nextToken());请问是哪里错了 java错误,新人求指点。。。谢谢 java内存回收机制与对象close()方法的问题 数组作为参数传递 写个阅读器 阅读章节怎么做??? 怎么下载JAVA,怎么装呢? 关于java IO 流的问题 推荐本关于Java的书 用java写收发邮件的程序,求助!在线 sun的ftp服务器 这个构造函数new String(byte[],int,int,int)怎麽用?谢谢! 请教FileOutputStream的用法 郁闷中!大虾请进!关于类方法的参数传递问题
String str = "aaaaaaaaaa";
fos.write(str.getBytes());
fos.flush();
fos.close();
public void actionPerformed(ActionEvent e){
JFileChooser c = new JFileChooser();
FileOutputStream fos = new FileOutputStream(c.getCurrentDirectory().toString());
String str = new String();
str = "aaa";
fos.wirte(str.getBytes());
fos.flush();
fos.close();
}
}那我这么写对吗,提示有错误啊,请帮忙看看哪里错了,谢谢
String str = "aaaaaaaaaa";
fos.write(str.getBytes());
fos.flush();
fos.close();用上面这些代码的时候,提示cannot resolve symbol,是fos.write(str.getBytes());这句,是不是没有import什么东西,我import java.io.*;,还需要import 什么吗?
// 读文件
FileInputStream fin =new FileInputStream("c:\\text.txt");
byte rec[] = new byte[1024];
fin.read(rec);
fin.close() ;
outstr = (new String(rec)).trim() ;
int i = Integer.parseInt(outstr);
// 文件读完,并将数据要 i 返回 // 将 i 加一,然后写文件
i = i + 1;
outstr = String.valueOf(i);
FileOutputStream fout1 =new FileOutputStream("c:\\text.txt");
fout1.write(outstr.getBytes());
fout1.close();
// 文件写完
BufferedWriter writeFile=new BufferedWriter(new FileWriter(selectFile)); //使用缓冲写入文件
String str=texts.getText();
writeFile.write(str.nextToken());
writeFile.flush();
writeFile.close();
不过我也是菜鸟
\在java中转意字符,和C语言一样的
\t代表tab,\n\r
\\代表\
上面的例子是个计数器的用处啊,outstr当然是String了
symbol: method nextToken()
location: class.java.lang.StringwriteFile.write(str.nextToken());请问是哪里错了