I have a method to return a string of the folder path. CSVFile method calls another method ConfigFilePath to extract the value from a config file and return it back to be used for another condition.
public CSVFile(ManagedElement_T[] meInfo) {
String path = null;
ConfigFilePath(path);
system.out.print("CSV "+path);
}
public String ConfigFilePath(String path) {
final String directory = System.getProperty("user.dir");
final String filename = "config.properties";
final File configFile = new File(directory+"/"+filename);
final Properties prop = new Properties();
InputStream input = null;
try {
input = new FileInputStream(configFile);
prop.load(input);
path = prop.getProperty("diretory_csv");
System.out.println("PATH " + path);
} catch (IOException ex) {
ex.printStackTrace();
} finally {
// Close the file
}
File checkPath = new File(path.toString());
System.out.println("CHECK " + checkPath);
if (checkPath.exists()) {
System.out.println("Directory already exists ...");
} else {
//mkdir if it does not exist
}
return path;
}
Problem is, it doesn't return any var path? just says null when I print it but inside the ConfigFilePath method it seems its getting the right values based from the prints in eclipse.
System.out.println("PATH " + path); = C:/opt/CORBA/input
System.out.println("CHECK " + checkPath); = C:\opt\CORBA\input
System.out.print("CSV "+path); = null