java - Java 中的 PrintWriter write() 与 print() 方法

标签 java file

<分区>

Java PrintWriter 类中的write()print() 方法有什么区别?

最佳答案

print() formats the output, while write() just prints the characters it is given. print() handles many argument types, converting them into printable strings of characters with String.valueOf(), while write() just handles single characters, arrays of characters, and strings.

To illustrate the difference, write(int) interprets the argument as a single character to be printed, while print(int) converts the integer into a character string. write(49) prints a "1", while print(49) prints "49".

来源:http://www.coderanch.com/t/398792/java/java/write-print

关于java - Java 中的 PrintWriter write() 与 print() 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30662642/

相关文章:

shell - 构建后将文件复制到docker镜像

c - C中文件操作期间的运行时错误

java - 数据核空间映射误差

java - 带有导入库的 Android Studio java.lang.NoSuchMethodError

java - 更新包含多种数据类型的 ArrayList

python - 只读取文件的第一行?

java - spring boot 不显示自定义错误页面

java - 是否可以在单元测试期间禁用 Spring 的 @Async?

java - 如果文本文件不存在则创建一个文本文件,如果存在则使用 Java BufferedWriter 附加到它

java - 如何使用java以位方式保存文件?