java - Reading filepath from properties file -


i'm trying read file filepath read properties, keep getting filenotfoundexception (the file exists).

test.properties:

test.value = "src/main/resources/file.csv" 

loadproperties.java:

public class loadproperties {     public static void main(string[] args) throws filenotfoundexception, ioexception {        properties aprop = new properties();       aprop.load(new fileinputstream("src/main/resources/test.properties")); // works        string filepath = aprop.getproperty("test.value");       system.out.println(filepath); // outputs: "src/main/resources/file.csv"        filereader areader = new filereader("src/main/resources/file.csv"); // works       filereader areader2 = new filereader(filepath); // java.io.filenotfoundexception    } } 

why exception being thrown while line above works fine? how should read file path provided properties?

you not supposed put " in property file. here java sees :

string file = "\"src/main/resources/file.csv\""; 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -