ok, this is a basic question
登录 | 论坛导航 -> 华新鲜事 -> 社会百科 | 本帖共有 5 楼,分 1 页, 当前显示第 1 页 : 本帖树形列表 : 刷新 : 返回上一页
<<始页  [1]  末页>>
作者:Cdarkrider (等级:2 - 初出茅庐,发帖:61) 发表:2003-05-26 01:39:51  楼主  关注此帖评分:
关于java的文件写入的两个问题~~不去学海深仇了有一个变量是account(String的) 建立account.sav格式的文件,应该怎么做? 要是把文件建立在save目录下面又怎么做呢? myFile = new File("/save",account); 这样可以吗? 谢谢先 学海深仇的斑竹给我打八卦~~~ 打死我也不去了
ok, this is a basic question
filename="/home/user/account.sav";
BufferedWriter writer=new BufferedWriter(new FileWriter(filename));
writer.write("whatever you want to write to the line"); writer.newLine();

//finally after u finish
writer.close();


use your own file name... windows file name like "C:/myfolder/saveing.sav";
or relative file locations...

and remember the call function must "throws IOException"
Put your OWN COOL signature here!
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:Cdarkrider (等级:2 - 初出茅庐,发帖:61) 发表:2003-05-26 01:48:39  2楼
account 是一个变量也可以这么写吗?
oh... my god
String filename="xxx.txt";
String account="xxx.txt";
String whatever="xxx.txt";

what is the difference???!!!!

please get a book and learn the very basic things first!

欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:Cdarkrider (等级:2 - 初出茅庐,发帖:61) 发表:2003-05-26 01:50:29  3楼 评分:
account 是一个变量也可以这么写吗?
oh ... my god
please get a book and read the very basic part first before ask further more.

String filename="xxx.txt";
String account="account.txt";
String whatever="xxx.txt";


except "String", no more keyword, you can change of coz!!!!
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:Cdarkrider (等级:2 - 初出茅庐,发帖:61) 发表:2003-05-26 02:03:27  4楼 评分:
~~~难道是这样? String account=account+".txt"; myFile = new File(newaccount); 对吗?
ok... see this

String account="your directoty/your filename without .txt";
account=account+".txt";
myFile = new File(newaccount);

and can you really "myfile=new File()"? i dont think so.
unless you decleared your own class.

note: pascal style is not working in Java

欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:Cdarkrider (等级:2 - 初出茅庐,发帖:61) 发表:2003-05-26 02:08:18  5楼
非常感谢你的解答,是少写了一个File新手上路~~ 请多指教:$
welcome
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
论坛导航 -> 华新鲜事 -> 社会百科 | 返回上一页 | 本主题共有 5 篇文章,分 1 页, 当前显示第 1 页 | 回到顶部
<<始页  [1]  末页>>

请登录后回复:帐号   密码