Java - Eclipse:外部化字符串?
看起来“外部化字符串”功能占据了一切,创建了一个 Messages
类,以及一个用于存储字符串本身的 .txt 文件。这很有趣,但我有另一种方法来存储常量:
public final class Constants {
//for parsing commands
public static final String REGEX_COMMAND = "(\\w*) *= *\"(.*)\""; //Regex for a command from a data file
//etc
}
有没有办法让 Eclipse 自动将字符串和其他值移到这里?
It looks like the "Externalize Strings" feature takes everything, makes a Messages
class, and a .txt file in which to store the Strings themselves. This is interesting, but I've got another way to store constants:
public final class Constants {
//for parsing commands
public static final String REGEX_COMMAND = "(\\w*) *= *\"(.*)\""; //Regex for a command from a data file
//etc
}
Is there any way to get Eclipse to automatically move Strings and other values to here for me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
选择一个文字,右键,Refactor ->提取常量...继续向导。
Select a literal, right click, Refactor -> Extract Constant... proceed with the wizard.
没有办法自动移动琴弦。
如果您需要手动移动多个字符串常量,最方便的方法是通过拖放:选择所需的字符串,然后将它们拖到您的 Constants 类中。
There is no way to move the strings automatically.
If you need to move several String constants by hand, the most convenient way to do that is through drag and drop: select the strings you want, and drag them to your Constants class.