日期:2014-05-20  浏览次数:20874 次

怎样将一个字符串转化成char数组
一个字符串怎样转化成字符数组?
char []c = new char[1024];
然后再由BufferedWriter 写入到文件里面呢?

------解决方案--------------------
Java code
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;

public class Test
{
    public static void main(String[] args) throws Exception
    {
        String s = "Hello World";

        char[] c = s.toCharArray();

        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(
                new FileOutputStream("D:\\d.txt")));
        
        bw.write(c);
        
        bw.close();
    }
}