Command line interface (Terminal) application

I have been quite happy studying Java with Mosh and now meet up these challenges to solve please can you help me with tips to solve this problem below:
I have a folder called asset that contains 2 sub folders .mp3 files and .png files.
I also have the .txt file with information of the songs , name , artists, albums, genre, file names and albums images . Now I need to read this files to display the list of songs and other features

  1. Play a song : when enter #1 on the main menu the app shows the list of songs by reading the text file
  2. Filter by artists: when enter #2 on the main menu, the app will replace the main menu options with list of artists on the .txt file
  3. Filter by albums: when enter #3 on the main menu it replaced it with list of albums available in the .txt file
  4. Filter by genre: enter #4 on the main menu to show list of genres
  5. Search : enter #5 on the main menu to allow you perform search base on the names of the songs

This is a command line interface (terminal) app that doesn’t have user interface. Please I need tips on how to connect Thank you all!

Is there a particular part of this project that you are having trouble with? It is a bit much to ask the community here at codewithmosh to fully implement a sizeable project like this.

It sounds like the majority of the application is just reading the data from the .txt file and then populating appropriate data structures for returning that data.

So here are a few questions back to you:

  1. Have you figured out how to read the content of the .txt file?
  2. Do you know what sorts of data structures you might use for this application? For example: arrays, lists, sets, tries, etc
  3. Have you designed one or more classes to hold the song and album data? If so, what do those look like?

I have designed some classes and I can input data through a scanner and the data structures i am using is arrays, my concerned is how to read the .txt file

There are many ways to read a file. I am assuming the file is using CSV (Comma Separated Values; for example: “field1,field2,field3”).

The simplest way is probably to use java.io.BufferedReader:

List<String[]> records = new ArrayList<>();
try (BufferedReader br = new BufferedReader(new FileReader("file.txt"))) {
    for (String line = br.readLine(); line != null; line = br.readLine()) {
        String[] values = line.split(",");
        records.add(values);
    }
}

Here I am just aggregating everything into a List of arrays containing the lines split everywhere there is a comma.

NOTE: If you do have CSV data, it is also possible to use a library like OpenCSV which can make things even easier.

Thank you so much for the help I really do appreciate. Can I use same method to make java open a .mp3

Yes and no. If you try using a BufferedReader to read an MP3 file, it will just read a bunch of gibberish since the MP3 file encoding is not just string data. Remember that everything stored on a computer is just a bunch of 1s and 0s, so it will just try to interpret that as text, but it will look like gibberish.

Instead, you should use a library as I already mentioned over in Coding challenge - #2 by jmrunkle. If you use JLayer, you would end up with something like this:

try (Player jlPlayer = new Player(
  new BufferedInputStream(
    new FileInputStream(mp3FileToPlay)))) {
  jlPlayer.play();
}

NOTE: that is extremely simplified, but may still be useful for you.

Thanks again. This really help me !