使用Writer将int写入文本文件 [英] Write int to text file using Writer

查看:99
本文介绍了使用Writer将int写入文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Writer wr = new FileWriter("123.txt");
wr.write(123);
wr.close();

输出文件包含:

{

问题出在哪里?如何使用 Writer int 写入文本文件?

Where is the problem? How to write int to text file using Writer?

推荐答案

你必须写字符串......

You have to write String...

你可以试试。

wr.write("123");

OR

wr.write(new Integer(123).toString());

OR

wr.write( String.valueOf(123) );

这篇关于使用Writer将int写入文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆