public static void main(String[] agrs) throws IOException {
FileOutputStream out = null;
try {
out = new FileOutputStream(new File("D:/a.txt"));
// 將你的數據,轉換成某一個字符集的byte數組,然後直接寫入文件即可
out.write("digraph{node[fontname=\"SimSun\"];開始->結束;}".getBytes("UTF-8"));
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
out.close();
}
}
生成的圖片: