So, my data are stored in a file, called log.txt, and I want to view the content of it, in GUI. So i've got these two classes which i'm using, one is Engine, where I read the log.txt file, and the other one is GUI, where is used to apply the methods used in Engine.

So, in my engine, I've got these codes:

```
public void loadLog()
    {
        try
        {
            java.io.File cpFile = new java.io.File( "log.txt" );

            if ( cpFile.exists() == true )
            {
                File file = cpFile;

                FileInputStream fis = null;
                BufferedInputStream bis = null;
                DataInputStream dis = null;

                String strLine="";
                String logPrint="";

                fis = new FileInputStream ( file );

                // Here is BufferedInputStream added for fast reading
                bis = new BufferedInputStream ( fis );
                dis = new DataInputStream ( bis );

                // New Buffer Reader
                BufferedReader br = new BufferedReader( new InputStreamReader( fis ) );

                while ( ( strLine = br.readLine() ) != null )
                {
                    StringTokenizer st = new StringTokenizer ( strLine, ";" );

                    while ( st.hasMoreTokens() )
                    {
                        logPrint       = st.nextToken();
                        System.out.println(logPrint);

                    }

                    log = new Log();
                    //regis.addLog( log );

                }
            }

        }
        catch ( Exception e ){
        }
    }

```

and then, in my GUI, I'd try to apply the codes used in my engine:

```
                    // create exit menu
        Logout = new JMenu("Exit");

        // create JMenuItem for about menu
        reportItem   = new JMenuItem ( "Report" );

        // add about menu to menuBar
        menuBar.add ( Logout );
        menuBar.setBorder ( new BevelBorder(BevelBorder.RAISED) );

        Logout.add ( reportItem );

    /* --------------------------------- ACTION LISTENER FOR ABOUT MENU ------------------------------------------ */

        reportItem.addActionListener ( new ActionListener()
        {
            public void actionPerformed ( ActionEvent e )
            {

                    engine.loadLog();
                    mainPanel.setVisible (false);
                    mainPanel = home();
                    toolBar.setVisible(false);
                    vasToolBar.setVisible(false);
                    cpToolBar.setVisible(false);
                    add ( mainPanel, BorderLayout.CENTER );
                    add ( toolBar, BorderLayout.NORTH );
                    toolBar.setVisible(false);
                    mainPanel.setVisible ( true );
                    pack();
                    setSize(500, 500);
            }
        });

```

NOW,

my question is, how can I print out whatever is read in my Engine's method, inside the GUI part? I want them to be either inside a JLabel or JTextArea. How am I supposed to do that?
['https://Stackoverflow.com/questions/13212654', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1748691/']
Perhaps you want your loadLog method to *return* a String that holds the text that it read from the file, and then in the GUI call the method and display the returned String as you desire. Also, never have an empty catch block when doing I & O.
Forgive me if I am misunderstanding your question, but here goes nothing:

You're going to want to read your text file line by line, and add each line to the JTextArea.

```
        BufferedReader reader = new BufferedReader(new FileReader("pathToFile"));  //This code creates a new buffered reader with the specified file input.  Replace pathToFile with the path to your text file.
        String text = reader.readLine();
        while(text != null) {
        myTextArea.append("\n" + text);  //Replace myTextArea with your JTextArea
        text = reader.readLine();
        }

```