Hello and thank you for taking the time to look at this question.

I am having trouble accessing a text file in a folder parallel to my src folder (see below for structure). 

The closest I have found to an explanation is here: <https://www.cis.upenn.edu/~matuszek/cit597-2006/Pages/finding-files.html>
and I have come across many similar questions but none from which I can infer the answer to this one unfortunately.

I know I could use absolute paths but I want to make sure that this software will work on other people's computers so that's a no-go. Therefore, I am trying to get it to work with relative paths.

As a bonus, it is suggested here: <https://coderanch.com/t/464197/java/java/Reading-files-directory-giving-relative> that in order for this code to work inside a JAR file, I'll have to use getResourceAsStream(). Could anyone advise?

I am trying to access Recipes.txt from within RecipeReader.java, here is my code so far:

```
        Class thisClass = this.getClass();
        ClassLoader loader = thisClass.getClassLoader();
        URL recipeFileURL = loader.getResource("Recipes.txt");
        String path = recipeFileURL.getPath();
        path.replaceAll("%20",  " ");
        BufferedReader input = new BufferedReader(new FileReader(path));

```

and similarly to write to the same file:

```
        Class thisClass = this.getClass();
        ClassLoader loader = thisClass.getClassLoader();
        URL recipeFileURL = loader.getResource("Recipes.txt");
        String path = recipeFileURL.getPath();
        path.replaceAll("%20",  " ");
        BufferedWriter output = new BufferedWriter(new FileWriter(path));

```

Thank you in advance for your help!

Robin

[![Eclipse Tree View](https://i.stack.imgur.com/O8qTy.png)](https://i.stack.imgur.com/O8qTy.png)