I want to get File from project folder by using \"File class\" , How I can Do that ?
File file=new File(\"x1.txt\");
If you don't specify any path and put just the file (Just like you did), the default directory is always the one of your project (It's not inside the "src" folder. It's just inside the folder of your project).
These lines worked in my case,
ClassLoader classLoader = getClass().getClassLoader();
File fi = new File(classLoader.getResource("test.txt").getFile());
provided test.txt file inside src
String path = System.getProperty("user.dir")+"/config.xml";
File f=new File(path);