如何使用DataOutputStream的writeChars方法将Java String值作为字符序列写入文件。
/** from nowjava - 时 代 Java**/ import java.io.DataOutputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void main(String[] args) { String strFilePath = "C://Folder//WriteStringAsChars.txt"; try { FileOutputStream fos = new FileOutputStream(strFilePath); DataOutputStream dos = new DataOutputStream(fos); String str = "This string will be written to file as sequence of characters!";//from N o w J a v a . c o m dos.writeChars(str);