Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java - Eclipse: Externalize Strings?

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?

like image 320
Nick Heiner Avatar asked Oct 13 '09 04:10

Nick Heiner


1 Answers

Select a literal, right click, Refactor -> Extract Constant... proceed with the wizard.

like image 138
Asaph Avatar answered Oct 13 '22 12:10

Asaph