Java Question I need to change FileReader file new FileRead

Java Question

I need to change

FileReader file = new FileReader(\"frank.txt\");

BufferedReader br = new BufferedReader(file);

to accept any txt file via commandline argument./

How can I do that?

Solution

import java.io.File; public class FileProcessing { public static void main(String[] args) { if(args.length > 0) { File file1 = new File(args[0]); //args[0] is command line argument and File class is used to create or search the file you want to use } } }
Java Question I need to change FileReader file = new FileReader(\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site