I am making a simple program to read a file to get data from it for a project.I have hard coded the file name and directory in my Java code. But now I want to pass my file name as a command line argument in my program.Is there an easy way to do it?
Thanks!
            Asked
            
        
        
            Active
            
        
            Viewed 1,298 times
        
    -1
            
            
         
    
    
        Aditya
        
- 65
- 1
- 11
- 
                    Have a look at Oracle's documentation [here](https://docs.oracle.com/javase/tutorial/essential/environment/cmdLineArgs.html). – Darshan Mehta Jul 01 '17 at 08:06
2 Answers
0
            
            
        In your main method, there should be a parameter that is an array of strings. This paremeter holds the tokenized command line arguments passed when your program is executed.
 
    
    
        Logan McMillan
        
- 1
- 3
0
            
            
        If you run your app from command lines, then you can use argv[0] for full path or "%1" for file name only in your properties inspector.
 
    
    
        Lawliet
        
- 3,438
- 2
- 17
- 28