over 3 years ago
    Path file = null;
    BufferedWriter bufferedWriter  = null;
    try{
        file = Files.createFile(Paths.get("D:\\SimpleNIOData.txt"));

        String line = "I am writing using NIO.鑫峯";
        bufferedWriter = Files.newBufferedWriter(file, Charset.forName("UTF-8"));
        bufferedWriter.write(line);
        bufferedWriter.flush();
        bufferedWriter.close();

    }catch(IOException e){
        e.printStackTrace();
    }finally{
        try{
            bufferedWriter.close();
        }catch(IOException ioe){
            ioe.printStackTrace();
        }
    }
← Iterator-代選器-抓出集合物件裡的Key 處理HttpServletRequest request →
 
comments powered by Disqus