Q:

Java - How to fill combobox with certain part of txt file

I have text file like this: 
   Jordan|Turner|jotu|12345|Department of Complaints|Belgrade|
   Travis|Bickle|trabic|54321|Driving Department|Novi Sad|

And code like this:
    package gui;
    public class ReservationWindow extends JFrame {

        private JComboBox cbDispatcher;
        private JLabel lblDispatcherecer;

        public ReservationWindow() {
            setTitle("Reservations");
            ImageIcon ikonica = new ImageIcon
                    (LoginProzor.class.getResource("/ikonice/faketaxi.png"));
            setIconImage(ikonica.getImage());
            setSize(400, 350);
            setDefaultCloseOperation(JFrame. DISPOSE_ON_CLOSE);
            setLocationRelativeTo(null);
            setResizable(false);
            initGUI();
            initActions();
        }

        private void initActions() {
 //here is everything fine :D
        }

        private void initGUI() {
            MigLayout mig = new MigLayout("wrap 2", "[][]", "[]10[][]10[]");
            setLayout(mig);

            cbDispatcher = new JComboBox();
            lblDispatcher = new JLabel("Dispatcher with whom you talked");

            add(lblDispatcher);
            add(cbDispatcher);

        }
    }

Now, how to fill ComboBox with certain part of the linse?  
(in this case with 4th part - Department of Complaints and Driving Department)

A:

If you are using | in file just for separator then I will suggest remove that and keep each value on each new line for simplicity, java 8 simple way to read file is :
List<String> list = new ArrayList<>();

try (Stream<String> stream = Files.lines(Paths.get(fileName))) {

    list = stream.collect(Collectors.toList());

    } catch (IOException e) {
        e.printStackTrace();
}

So now list will have all the values from file.  Now you have to loop on it and add it to JComboBox using cbDispatcher.addItem(value).  You can use stream.filter to filter (read specific part of file) and give it to JComboBox

