J
John Smith
I have a Constants class and a Variable class.
I need to initialize a constant in the Constants class:
public static final String FILE_NAME;
The Variable class has a public String method that returns the full
pathway for the file name.
public String getVariable( String variableName ) throws Exception;
I have a getPath() method in Constants that calls getVariable in
Variable:
private static String getPath( String variableName ) throws Exception {
try {
Variable v = new Variable();
return v.getVariable( variableName );
}
catch ( Exception e )
{
throw e;
}
}
Now to initialize Constants.FILE_NAME, I need to call getPath() to pick
up the pathway.
If I do:
public static final String FILE_NAME = Constants.getPath( "PATH_NAME"
);
I got an "unhandled exception error".
If I wrap "public static final String FILE_NAME = Constants.getPath(
"PATH_NAME" );"
with a try-catch block as follows:
try {
public static final String FILENAME = Constants.getPath("PATH_NAME");
}
catch (Exception e){
throw e;
}
I got:
Syntax error, insert } to complete block
Syntax error on tokens, constructor ConstructorHeaderName expected
instead.
How do I go about initializing the value of FILE_NAME? I *must* use
Variable::getVariable().
Thanks for your help.
I need to initialize a constant in the Constants class:
public static final String FILE_NAME;
The Variable class has a public String method that returns the full
pathway for the file name.
public String getVariable( String variableName ) throws Exception;
I have a getPath() method in Constants that calls getVariable in
Variable:
private static String getPath( String variableName ) throws Exception {
try {
Variable v = new Variable();
return v.getVariable( variableName );
}
catch ( Exception e )
{
throw e;
}
}
Now to initialize Constants.FILE_NAME, I need to call getPath() to pick
up the pathway.
If I do:
public static final String FILE_NAME = Constants.getPath( "PATH_NAME"
);
I got an "unhandled exception error".
If I wrap "public static final String FILE_NAME = Constants.getPath(
"PATH_NAME" );"
with a try-catch block as follows:
try {
public static final String FILENAME = Constants.getPath("PATH_NAME");
}
catch (Exception e){
throw e;
}
I got:
Syntax error, insert } to complete block
Syntax error on tokens, constructor ConstructorHeaderName expected
instead.
How do I go about initializing the value of FILE_NAME? I *must* use
Variable::getVariable().
Thanks for your help.