Reputation: 2663
I am trying to pass in two .wav files to my program through the command line.
In Main() I have tried casting them to be a File
File(args[0])
This don't work.If I want to be able to use the .wav files I pass in as command line args what do I need to do?
Upvotes: 1
Views: 3425
Reputation: 11531
Assuming that you want to open the files, remember that File
in Java is an object that stores path and name information. Once you have created the file objects, you can use them to construct a FileInputStream
or one of its children.
Upvotes: 0
Reputation: 30583
You cannot pass files as command line arguments, you have to pass file names as command line arguments and open that file in main function
Upvotes: 1
Reputation: 26
You need to pass in the url of the files via command line and then create new files from the urls.
public static void main(String[] args) {
File file1 = new File(args[0]);
File file2 = new File(args[1]);
Upvotes: 1