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/']
File IO operations are considered blocking/time consuming.

You should avoid running them in the Event Dispatching Thread, as this will prevent the UI from begin updated, making your application look like its hung/crashed

You could use a [`SwingWorker`](http://docs.oracle.com/javase/7/docs/api/javax/swing/SwingWorker.html) to perform the file loading part, passing each line to the `publish` method and adding the lines to the text area via the `process` method...

```
public class FileReaderWorker extends SwingWorker<List<String>, String> {

    private final File inFile;
    private final JTextArea output;

    public FileReaderWorker(File file, JTextArea output) {
        inFile = file;
        this.output = output;
    }

    public File getInFile() {
        return inFile;
    }

    public JTextArea getOutput() {
        return output;
    }

    @Override
    protected void process(List<String> chunks) {
        for (String line : chunks) {
            output.append(line);
        }
    }

    @Override
    protected List<String> doInBackground() throws Exception {
        List<String> lines = new ArrayList<String>(25);
        java.io.File cpFile = getInFile();
        if (cpFile != null && cpFile.exists() == true) {
            File file = cpFile;

            BufferedReader br = null;

            String strLine = "";
            String logPrint = "";
            try {
                // New Buffer Reader
                br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
                while ((strLine = br.readLine()) != null) {
                    StringTokenizer st = new StringTokenizer(strLine, ";");
                    while (st.hasMoreTokens()) {
                        logPrint = st.nextToken();
                        publish(logPrint);
                    }
                }
            } catch (Exception e) {
                publish("Failed read in file: " + e);
                e.printStackTrace();
            } finally {
                try {
                    if (br != null) {
                        br.close();
                    }
                } catch (Exception e) {
                }
            }
        } else {
            publish("Input file does not exist/hasn't not begin specified");
        }            
        return lines;
    }
}

```

Take a look at [Lesson: Concurrency in Swing](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html) for more information
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.