英文:
I can't make new line with "\n" on JDA
问题
第一次在这里寻求帮助,所以如果我的帖子格式有误,我很抱歉。我的问题是我无法在Java的JDA(Java Discord API)中换行。
当我使用:
eb.setDescription("For \n Example");
它运行得很好,但我正在尝试做这个。
首先,我从配置文件中获取字符串:
String Message = plugin.getConfig().getString("Discord." + "PrivateMessage");
它可以成功地获取字符串,但当我使用 eb.setDescription(Message);
时,消息没有换行。消息中有换行符 \n
,但它们并没有创建新的换行。消息显示如下:
"For \n Example" 没有新行。
英文:
first time I am asking for help in here so If my thread format is wrong I am so sorry.My problem is I can't make new line in Java JDA(Java Discord API).
When I use:
eb.setDescription("For \n Example");
It works just fine but I am trying to do this.
First I am getting string from config file:
String Message = plugin.getConfig().getString("Discord." + "PrivateMessage")
It gets the String fine but when I use eb.setDescription(Message);
Message coming without lines. There are new line brackets "\n" in message but they are not making new lines.Message coming like:
"For \n Example" without new lines.
答案1
得分: 1
我假设你实际的字符串在一个文件中,你刚刚将它读出。当你在文件中放入 \n
时,在读取时它不会自动转换为换行符。你可以使用 string = string.replace("\\n", "\n")
进行转换。
英文:
I'm assuming your actual string is in a file and you just read it out. When you put \n
in a file that doesn't automatically convert to a newline when you read it. You can do string = string.replace("\\n", "\n")
to convert it.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论