Hello, I'm trying to write a program that takes an input file name and lists the folders in a heirarchy

ex.Folder
      subfolder
      etc

I have most of my code, but I'm getting 2 errors that are connected and I have no idea how to fix it.

Here is my code:

import java.util.Scanner;
import java.io.File;


public class TreeStructure
{

    public static void main(String[] args)
    {
        if(0 < args.length)
        {
            String folderName = args[0];
            File folder = new File(folderName);
        }


        Scanner input = new Scanner(System.in);
        System.out.println("Enter a folder name");
        System.out.flush();
        String folderName = input.nextLine();
        File folder = new File(folderName);
        treeTraversal(folder, folderName);


    }


    public static void treeTraversal(File parent_Node, String heirarchy_Lines)
    {
        if(parent_Node.isDirectory())
        {
            System.out.println(heirarchy_Lines + parent_Node);
            heirarchy_Lines += "--------";
            File child_Node[] = parent_Node.listFiles();
            for(File child_Node : children_Node)
            {
                treeTraversal(child_Node, heirarchy_Lines);
            }
        }

        else
        {
            System.out.println(heirarchy_Lines + parent_Node);
        }
    }

}

And here are my errors:

   C:\Users\Desktop\TreeStructure.java:35: error: variable child_Node is already defined in method treeTraversal(File,String)
                for(File child_Node : children_Node)
                         ^
    C:\Users\Desktop\TreeStructure.java:35: error: cannot find symbol
                for(File child_Node : children_Node)
                                      ^
      symbol:   variable children_Node
      location: class TreeStructure
    2 errors

Any and all help will be appreciated, just a little not that I am a beginner, thanks!

Nevermind, figured it out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.