java写"\n"写入到txt文本用记事本打开出现黑框解决方案

 列子:

	public static void main(String[] args) throws IOException {
		File file = new File("F:\\jimmy\\a.txt");
		if(!file.exists())
			file.createNewFile();
		OutputStream out = new FileOutputStream(file);
		out.write(new String("我\n勒\n了\n个\n去").getBytes());
		out.close();
	}


打开文本,里面内容为:我■勒■了■个■去。解决方案是将\n改为\r\n。

你可能感兴趣的:(java,String,File)