本文介绍了\ n不起作用,不换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在创建一个小程序,该程序将int值保存到文本文件中,进行保存,然后在再次启动该程序时将其加载.现在,我需要再将3个布尔值存储在文本文件中,我正在使用

I'm creating a small program that saves a int value into a text file, saves it, and loads it when you start the program again. Now, I need 3 more booleans to be stored in the text file, I am writing things in the file with

    public Formatter x;

x.format("%s", "" + m.getPoints() + "\n");

每当我想使用\ n转到文本文件中的新行时,都不会转到新行,它将直接写在int值后面.我都尝试过

Whenever I want to go to a new line in my text file, with \n, it wont go to a new line, it will just write it directly behind the int value. I tried doing both

        x.format("%s", "" + m.getPoints() + "\n");
    x.format("%s", "" + m.getStoreItem1Bought() + "\n");

    x.format("%s%s", "" + m.getPoints() + "\n", "" + m.getBought() + "\n");

但是,两者都将布尔值直接写在int值后面,而无需开始新行.有什么帮助吗?

but, both will just write the boolean directly behind the int value, without starting a new line. Any help on this?

我正在使用Windows 7 Ultimate 64位,并且我的文本编辑器是Eclipse,我也在Eclipse中运行所有代码.

I am using Windows 7 Ultimate 64 bits, and my text editor is Eclipse, I am running all of the code with Eclipse too.

推荐答案

更具体地说,我建议使用:

More specifically, I would recommend using:

x.format("%d%n%s%n", m.getPoints(), m.getStoreItem1Bought());

这篇关于\ n不起作用,不换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 20:34