在Eclipse中粘贴多行Java字符串 [英] Paste a multi-line Java String in Eclipse

查看:292
本文介绍了在Eclipse中粘贴多行Java字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不幸的是,Java没有多行字符串文字的语法。没有问题,如果IDE使其易于使用如

  String x =CREATE TABLE TEST(\\\

+A INTEGER NOT NULL PRIMARY KEY,\\\

...

使用Eclipse将多行字符串从剪贴板粘贴到Java源中(以自动创建如上所述的代码)的最快方式是什么?

解决方案

好的,我刚刚找到答案< a>(在Stackoverflow,不少于)。



Eclipse有一个选项,以便将多行文本复制粘贴到字符串文字中将导致引用的换行符: p>


首选项/ Java / Editor / Typing /粘贴到字符串文字时转义文本



Unfortunately, Java has no syntax for multi-line string literals. No problem if the IDE makes it easy to work with constructs like

  String x = "CREATE TABLE TEST ( \n"
             + "A INTEGER NOT NULL PRIMARY KEY, \n"
            ...

What is the fastest way to paste a multi-line String from the clipboard into Java source using Eclipse (in a way that it automatically creates code like the above).

解决方案

Okay, I just found the answer (on Stackoverflow, no less).

Eclipse has an option so that copy-paste of multi-line text into String literals will result in quoted newlines:

Preferences/Java/Editor/Typing/ "Escape text when pasting into a string literal"

这篇关于在Eclipse中粘贴多行Java字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆