Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 13 of 13

Thread: [help] how to put the output in TextArea

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default [help] how to put the output in TextArea

    hi guys im having a trouble here in my code

    i can't transfer my output in TextArea

    the error said non-static variable TAShaReport cannot be referenced from a static context

    can you help me ...

    thanks for advance

    here is the code

        public static String DeduplicateFiles(String myFolderLocation) 
        {
            try 
                {
                    HashSet<String> newset = new HashSet<>();
                    File folder = new File(myFolderLocation);  //Directory where the files are located
                    File[] listOfFiles = folder.listFiles();
     
                    for (File listOfFile : listOfFiles) 
                        {
                            //Enumerate the files inside the folder
                            if (listOfFile.isFile()) 
                                {
                                    String myMD5 = getMD5Checksum(listOfFile.getPath());
                                    if (newset.contains(myMD5)) 
                                        {
                                            DuplicateCount++;
                                            System.out.println(listOfFile.getName() + "," + myMD5 + ", DUPLICATE");
                                            File myFilePath = new File(listOfFile.getPath());
                                            myFilePath.delete();
                                        } 
                                    else 
                                        {
                                            UniqueCount++;
                                            System.out.println(listOfFile.isDirectory() + "," + myMD5 + ", UNIQUE");
                                            newset.add(myMD5);
                                        } 
                               } 
                            else if (listOfFile.isDirectory()) 
                                {
                                    System.out.println("Directory " + listOfFile.getName());
                                }
                        }
                } 
            catch (Exception e) 
                {
                }
            return null;
        }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 634 Times in 540 Posts

    Default Re: [help] how to put the output in TextArea

    Why is this method static?

    What happened when you googled the error?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Sep 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [help] how to put the output in TextArea

    i dont know

    this is my whole program

    /*
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    */
    package gridmanualprocessor;

    import javax.swing.*;
    import java.io.*;
    import java.util.HashSet;
    import java.security.MessageDigest;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Date;

    /**
    *
    * @author admin
    */
    public class GridManualProcess extends javax.swing.JFrame {

    /**
    * Creates new form GridManualProcess
    */
    public GridManualProcess() {
    initComponents();
    }

    /**
    * This method is called from within the constructor to initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is always
    * regenerated by the Form Editor.
    */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    jLabel1 = new javax.swing.JLabel();
    TxtFilePath = new javax.swing.JTextField();
    BSelectFolder = new javax.swing.JButton();
    BRunProgram = new javax.swing.JButton();
    jLabel2 = new javax.swing.JLabel();
    jScrollPane1 = new javax.swing.JScrollPane();
    TAUniqueCount = new javax.swing.JTextArea();
    jScrollPane2 = new javax.swing.JScrollPane();
    TAShaReport = new javax.swing.JTextArea();
    jLabel3 = new javax.swing.JLabel();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenu2 = new javax.swing.JMenu();

    setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);
    setTitle("Grid Manual Processor");
    setBackground(java.awt.Color.red);
    setResizable(false);

    jLabel1.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
    jLabel1.setText("File Path:");

    TxtFilePath.setEditable(false);

    BSelectFolder.setText("Select Folder");
    BSelectFolder.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    BSelectFolderActionPerformed(evt);
    }
    });

    BRunProgram.setText("Run Program");
    BRunProgram.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    BRunProgramActionPerformed(evt);
    }
    });

    jLabel2.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
    jLabel2.setText("Download and Unique Count:");

    TAUniqueCount.setEditable(false);
    TAUniqueCount.setColumns(20);
    TAUniqueCount.setRows(5);
    jScrollPane1.setViewportView(TAUniqueCount);

    TAShaReport.setEditable(false);
    TAShaReport.setColumns(20);
    TAShaReport.setRows(5);
    jScrollPane2.setViewportView(TAShaReport);

    jLabel3.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
    jLabel3.setText("Sha1 Report:");

    jMenu1.setText("File");
    jMenuBar1.add(jMenu1);

    jMenu2.setText("Edit");
    jMenuBar1.add(jMenu2);

    setJMenuBar(jMenuBar1);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(20, 20, 20)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING, false)
    .addGroup(layout.createSequentialGroup()
    .addComponent(jLabel1)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addComponent(TxtFilePath, javax.swing.GroupLayout.PREFERRED_SIZE, 350, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(BSelectFolder)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addComponent(BRunProgram))
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jLabel2))
    .addGap(18, 18, 18)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(jLabel3)
    .addComponent(jScrollPane2))))
    .addContainerGap(23, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(jLabel1)
    .addComponent(TxtFilePath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(BSelectFolder)
    .addComponent(BRunProgram))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(jLabel2)
    .addComponent(jLabel3))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
    .addComponent(jScrollPane1))
    .addContainerGap())
    );

    pack();
    }// </editor-fold>

    private void BSelectFolderActionPerformed(java.awt.event.Action Event evt) {
    // TODO add your handling code here:
    FCFolderPath = new JFileChooser();
    FCFolderPath.setCurrentDirectory(new java.io.File("C:\\Harvest\\"));
    FCFolderPath.setDialogTitle("Folder Path");
    FCFolderPath.setFileSelectionMode(JFileChooser.DIR ECTORIES_ONLY);
    int result = FCFolderPath.showDialog(this,"Select Folder");

    if (result == JFileChooser.APPROVE_OPTION)
    {
    File file = FCFolderPath.getSelectedFile();
    TAShaReport.setText(file.getAbsolutePath());
    }
    }

    private void BRunProgramActionPerformed(java.awt.event.ActionEv ent evt) {
    // TODO add your handling code here:
    String filepaths = TxtFilePath.getText();
    String PWord = "PWord";
    String DBUrl = "DBUrl";
    String UName = "UName";
    String SiteInitial = "SiteInitial";
    String OJTNumber = "OJTNumber";

    if ("".equals(TxtFilePath.getText()))
    {
    JOptionPane.showMessageDialog(null, "PLEASE CHOOSE A FOLDER PATH","MESSAGE ALERT",JOptionPane.ERROR_MESSAGE);
    }
    else
    {
    try
    {
    DeduplicateFiles(filepaths);
    //MyUniqueReporting();
    System.out.println("\tProcess done.\n\n");
    }
    catch(Exception e)
    {

    }

    }
    }

    public static byte[] createChecksum(String filename) throws Exception
    {
    MessageDigest complete;
    try (InputStream fis = new FileInputStream(filename))
    {
    byte[] buffer = new byte[1024];
    complete = MessageDigest.getInstance("MD5");
    int numRead;
    do
    {
    numRead = fis.read(buffer);
    if (numRead > 0)
    {
    complete.update(buffer, 0, numRead);
    }
    }
    while (numRead != -1);
    }
    return complete.digest();
    }

    public static String DeduplicateFiles(String myFolderLocation)
    {
    try
    {
    HashSet<String> newset = new HashSet<>();
    File folder = new File(myFolderLocation); //Directory where the files are located
    File[] listOfFiles = folder.listFiles();

    for (File listOfFile : listOfFiles)
    {
    //Enumerate the files inside the folder
    if (listOfFile.isFile())
    {
    String myMD5 = getMD5Checksum(listOfFile.getPath());
    if (newset.contains(myMD5))
    {
    DuplicateCount++;
    System.out.println(listOfFile.getName() + "," + myMD5 + ", DUPLICATE");
    File myFilePath = new File(listOfFile.getPath());
    myFilePath.delete();
    }
    else
    {
    UniqueCount++;
    System.out.println(listOfFile.isDirectory() + "," + myMD5 + ", UNIQUE");
    newset.add(myMD5);
    }
    }
    else if (listOfFile.isDirectory())
    {
    System.out.println("Directory " + listOfFile.getName());
    }
    }
    }
    catch (Exception e)
    {
    }
    return null;
    }

    public static String getMD5Checksum(String filename) throws Exception
    {
    byte[] b = createChecksum(filename);
    String result = "";

    for (int i = 0; i < b.length; i++)
    {
    result += Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1);
    }
    return result;
    }

    public static String MyUniqueReporting()
    {
    DateFormat NgayonAraw = new SimpleDateFormat("yyyy-MM-dd");
    Date Araw = new Date();
    PrintWriter MyUniqueReport;
    try
    {
    MyUniqueReport = new PrintWriter(new FileOutputStream(NgayonAraw.format(Araw)+"-UniqueReport.txt",true));
    int downloadCount = UniqueCount + DuplicateCount;
    int yieldCount = downloadCount - (DuplicateCount + KnownInACL + totalProvenanceBreakdown);
    MyUniqueReport.println("Folder Name: , Total Download Files: , Total Unique Files:");
    MyUniqueReport.println(downloadCount+yieldCount);
    MyUniqueReport.close();
    }
    catch (FileNotFoundException exc)
    {
    JOptionPane.showMessageDialog(null,"File not Found.");
    }
    return null;
    }

    private void fillGuiWithSha1Results(File f)
    {
    if (f.isDirectory())
    {
    //recurse?
    }
    else
    {
    try
    {
    // TAShaReport.setText(DeduplicateFiles(f)));
    }
    catch (Exception e)
    {
    }
    }
    }

    private void TxtFilePathActionPerformed(java.awt.event.ActionEv ent evt)
    {
    //TxtFilePath.getText(Chooses); // TODO add your handling code here:
    System.out.printf("TxtFilePathAcc");
    }



    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
    * For details see How to Set the Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)
    */
    try {
    for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
    if ("Nimbus".equals(info.getName())) {
    javax.swing.UIManager.setLookAndFeel(info.getClass Name());
    break;
    }
    }
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
    java.util.logging.Logger.getLogger(GridManualProce ss.class.getName()).log(java.util.logging.Level.SE VERE, null, ex);
    }
    //</editor-fold>

    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(() -> {
    new GridManualProcess().setVisible(true);
    });
    }

    public static Date date = new Date();
    public static SimpleDateFormat TodayDate = new SimpleDateFormat("yyyy-MM-dd");
    public static Integer UniqueCount = 0, DuplicateCount = 0, KnownInACL = 0, UnknownInACL = 0;
    public static Integer totalProvenanceBreakdown = 0, total_provenance = 0;
    public static String siteInitial = "";

    private javax.swing.JFileChooser FCFolderPath;
    // Variables declaration - do not modify
    private javax.swing.JButton BRunProgram;
    private javax.swing.JButton BSelectFolder;
    private javax.swing.JTextArea TAShaReport;
    private javax.swing.JTextArea TAUniqueCount;
    private javax.swing.JTextField TxtFilePath;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    // End of variables declaration
    }


    --- Update ---

    i dont know

    this is my whole program

    /*
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    */
    package gridmanualprocessor;

    import javax.swing.*;
    import java.io.*;
    import java.util.HashSet;
    import java.security.MessageDigest;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Date;

    /**
    *
    * @author admin
    */
    public class GridManualProcess extends javax.swing.JFrame {

    /**
    * Creates new form GridManualProcess
    */
    public GridManualProcess() {
    initComponents();
    }

    /**
    * This method is called from within the constructor to initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is always
    * regenerated by the Form Editor.
    */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    jLabel1 = new javax.swing.JLabel();
    TxtFilePath = new javax.swing.JTextField();
    BSelectFolder = new javax.swing.JButton();
    BRunProgram = new javax.swing.JButton();
    jLabel2 = new javax.swing.JLabel();
    jScrollPane1 = new javax.swing.JScrollPane();
    TAUniqueCount = new javax.swing.JTextArea();
    jScrollPane2 = new javax.swing.JScrollPane();
    TAShaReport = new javax.swing.JTextArea();
    jLabel3 = new javax.swing.JLabel();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenu2 = new javax.swing.JMenu();

    setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);
    setTitle("Grid Manual Processor");
    setBackground(java.awt.Color.red);
    setResizable(false);

    jLabel1.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
    jLabel1.setText("File Path:");

    TxtFilePath.setEditable(false);

    BSelectFolder.setText("Select Folder");
    BSelectFolder.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    BSelectFolderActionPerformed(evt);
    }
    });

    BRunProgram.setText("Run Program");
    BRunProgram.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    BRunProgramActionPerformed(evt);
    }
    });

    jLabel2.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
    jLabel2.setText("Download and Unique Count:");

    TAUniqueCount.setEditable(false);
    TAUniqueCount.setColumns(20);
    TAUniqueCount.setRows(5);
    jScrollPane1.setViewportView(TAUniqueCount);

    TAShaReport.setEditable(false);
    TAShaReport.setColumns(20);
    TAShaReport.setRows(5);
    jScrollPane2.setViewportView(TAShaReport);

    jLabel3.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
    jLabel3.setText("Sha1 Report:");

    jMenu1.setText("File");
    jMenuBar1.add(jMenu1);

    jMenu2.setText("Edit");
    jMenuBar1.add(jMenu2);

    setJMenuBar(jMenuBar1);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(20, 20, 20)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING, false)
    .addGroup(layout.createSequentialGroup()
    .addComponent(jLabel1)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addComponent(TxtFilePath, javax.swing.GroupLayout.PREFERRED_SIZE, 350, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(BSelectFolder)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addComponent(BRunProgram))
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jLabel2))
    .addGap(18, 18, 18)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(jLabel3)
    .addComponent(jScrollPane2))))
    .addContainerGap(23, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(jLabel1)
    .addComponent(TxtFilePath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(BSelectFolder)
    .addComponent(BRunProgram))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(jLabel2)
    .addComponent(jLabel3))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
    .addComponent(jScrollPane1))
    .addContainerGap())
    );

    pack();
    }// </editor-fold>

    private void BSelectFolderActionPerformed(java.awt.event.Action Event evt) {
    // TODO add your handling code here:
    FCFolderPath = new JFileChooser();
    FCFolderPath.setCurrentDirectory(new java.io.File("C:\\Harvest\\"));
    FCFolderPath.setDialogTitle("Folder Path");
    FCFolderPath.setFileSelectionMode(JFileChooser.DIR ECTORIES_ONLY);
    int result = FCFolderPath.showDialog(this,"Select Folder");

    if (result == JFileChooser.APPROVE_OPTION)
    {
    File file = FCFolderPath.getSelectedFile();
    TAShaReport.setText(file.getAbsolutePath());
    }
    }

    private void BRunProgramActionPerformed(java.awt.event.ActionEv ent evt) {
    // TODO add your handling code here:
    String filepaths = TxtFilePath.getText();
    String PWord = "PWord";
    String DBUrl = "DBUrl";
    String UName = "UName";
    String SiteInitial = "SiteInitial";
    String OJTNumber = "OJTNumber";

    if ("".equals(TxtFilePath.getText()))
    {
    JOptionPane.showMessageDialog(null, "PLEASE CHOOSE A FOLDER PATH","MESSAGE ALERT",JOptionPane.ERROR_MESSAGE);
    }
    else
    {
    try
    {
    DeduplicateFiles(filepaths);
    //MyUniqueReporting();
    System.out.println("\tProcess done.\n\n");
    }
    catch(Exception e)
    {

    }

    }
    }

    public static byte[] createChecksum(String filename) throws Exception
    {
    MessageDigest complete;
    try (InputStream fis = new FileInputStream(filename))
    {
    byte[] buffer = new byte[1024];
    complete = MessageDigest.getInstance("MD5");
    int numRead;
    do
    {
    numRead = fis.read(buffer);
    if (numRead > 0)
    {
    complete.update(buffer, 0, numRead);
    }
    }
    while (numRead != -1);
    }
    return complete.digest();
    }

    public static String DeduplicateFiles(String myFolderLocation)
    {
    try
    {
    HashSet<String> newset = new HashSet<>();
    File folder = new File(myFolderLocation); //Directory where the files are located
    File[] listOfFiles = folder.listFiles();

    for (File listOfFile : listOfFiles)
    {
    //Enumerate the files inside the folder
    if (listOfFile.isFile())
    {
    String myMD5 = getMD5Checksum(listOfFile.getPath());
    if (newset.contains(myMD5))
    {
    DuplicateCount++;
    System.out.println(listOfFile.getName() + "," + myMD5 + ", DUPLICATE");
    File myFilePath = new File(listOfFile.getPath());
    myFilePath.delete();
    }
    else
    {
    UniqueCount++;
    System.out.println(listOfFile.isDirectory() + "," + myMD5 + ", UNIQUE");
    newset.add(myMD5);
    }
    }
    else if (listOfFile.isDirectory())
    {
    System.out.println("Directory " + listOfFile.getName());
    }
    }
    }
    catch (Exception e)
    {
    }
    return null;
    }

    public static String getMD5Checksum(String filename) throws Exception
    {
    byte[] b = createChecksum(filename);
    String result = "";

    for (int i = 0; i < b.length; i++)
    {
    result += Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1);
    }
    return result;
    }

    public static String MyUniqueReporting()
    {
    DateFormat NgayonAraw = new SimpleDateFormat("yyyy-MM-dd");
    Date Araw = new Date();
    PrintWriter MyUniqueReport;
    try
    {
    MyUniqueReport = new PrintWriter(new FileOutputStream(NgayonAraw.format(Araw)+"-UniqueReport.txt",true));
    int downloadCount = UniqueCount + DuplicateCount;
    int yieldCount = downloadCount - (DuplicateCount + KnownInACL + totalProvenanceBreakdown);
    MyUniqueReport.println("Folder Name: , Total Download Files: , Total Unique Files:");
    MyUniqueReport.println(downloadCount+yieldCount);
    MyUniqueReport.close();
    }
    catch (FileNotFoundException exc)
    {
    JOptionPane.showMessageDialog(null,"File not Found.");
    }
    return null;
    }

    private void fillGuiWithSha1Results(File f)
    {
    if (f.isDirectory())
    {
    //recurse?
    }
    else
    {
    try
    {
    // TAShaReport.setText(DeduplicateFiles(f)));
    }
    catch (Exception e)
    {
    }
    }
    }

    private void TxtFilePathActionPerformed(java.awt.event.ActionEv ent evt)
    {
    //TxtFilePath.getText(Chooses); // TODO add your handling code here:
    System.out.printf("TxtFilePathAcc");
    }



    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
    * For details see How to Set the Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)
    */
    try {
    for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
    if ("Nimbus".equals(info.getName())) {
    javax.swing.UIManager.setLookAndFeel(info.getClass Name());
    break;
    }
    }
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
    java.util.logging.Logger.getLogger(GridManualProce ss.class.getName()).log(java.util.logging.Level.SE VERE, null, ex);
    }
    //</editor-fold>

    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(() -> {
    new GridManualProcess().setVisible(true);
    });
    }

    public static Date date = new Date();
    public static SimpleDateFormat TodayDate = new SimpleDateFormat("yyyy-MM-dd");
    public static Integer UniqueCount = 0, DuplicateCount = 0, KnownInACL = 0, UnknownInACL = 0;
    public static Integer totalProvenanceBreakdown = 0, total_provenance = 0;
    public static String siteInitial = "";

    private javax.swing.JFileChooser FCFolderPath;
    // Variables declaration - do not modify
    private javax.swing.JButton BRunProgram;
    private javax.swing.JButton BSelectFolder;
    private javax.swing.JTextArea TAShaReport;
    private javax.swing.JTextArea TAUniqueCount;
    private javax.swing.JTextField TxtFilePath;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    // End of variables declaration
    }

  4. #4
    Junior Member
    Join Date
    Sep 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [help] how to put the output in TextArea

    i dont know

    but this is my whole code

    its in the attachment
    Attached Files Attached Files

  5. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 634 Times in 540 Posts

    Default Re: [help] how to put the output in TextArea

    Why is this method static?

    What happened when you googled the error?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  6. #6
    Junior Member
    Join Date
    Sep 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [help] how to put the output in TextArea

    what do you mean?

  7. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 634 Times in 540 Posts

    Default Re: [help] how to put the output in TextArea

    I don't know how else to ask the question. Your method is static. Why? What reason do you have for making this static? Your whole problem is caused by a mismatch between a static method and non-static variables, and I predict it's because you don't understand what the static keyword is used for, so you're misusing it. You need to read up on when to use the static keyword. You do that by googling the error, or "java static keyword" or similar.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #8
    Junior Member
    Join Date
    Sep 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [help] how to put the output in TextArea

    what should i do ? to make that program run and put it in the text area ?

  9. #9
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 634 Times in 540 Posts

    Default Re: [help] how to put the output in TextArea

    You should learn the correct usage of the static keyword.

    This is the first result for googling "java static keyword": Understanding Class Members (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  10. #10
    Junior Member
    Join Date
    Sep 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [help] how to put the output in TextArea

    i already read that i dont understand that

    i just want to my program

    the output must be in the text area


    please help me i really need that

  11. #11
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 634 Times in 540 Posts

    Default Re: [help] how to put the output in TextArea

    What part of it don't you understand?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  12. #12
    Junior Member
    Join Date
    Sep 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [help] how to put the output in TextArea

    i already solved the problem

    i just remove the word static

    this is my 2nd problem

    is

    how do i get this out put

    example

    file path is : C:\\Desktop\\Fan\\Pfolr\\dse\\panget.txt

    this must be the output is

    dse , Panget.txt ?

  13. #13
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,797
    Thanks
    52
    Thanked 2,329 Times in 2,285 Posts

    Default Re: [help] how to put the output in TextArea

    Can you make a small, simple program for testing that compiles, executes and shows the problem?
    Be sure to wrap any posted code in code tags.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Transferring console output to a textArea....how to make this happen?
    By jakhondi21 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 12th, 2013, 05:03 PM
  2. Replies: 3
    Last Post: June 15th, 2013, 10:34 PM
  3. How to clear the textArea?
    By dynamix24 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 25th, 2013, 08:46 AM
  4. Store Values in 2D array and output to textarea
    By raverz1tildawn in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 7th, 2011, 03:13 PM
  5. [SOLVED] How to Put Spaces in the Output of Passed Arguments?
    By EmSaint in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 25th, 2010, 04:04 PM