Can someone help me understand the code below? I'm trying to figure out how it's getting the text file to read from.

public static void main(String[] args) throws Exception {

if( args.length < 2 )
{
throw new Exception( "Usage: inputFileName outputFileName");
}
Box d = new Box(8);

PrintWriter pw = new PrintWriter( new FileWriter(args[1]));
BufferedReader br = new BufferedReader( new FileReader( args[0] ));

From this code, you are passing the file as an argument i.e. at the time when you run the program. Probably a little study of 'String args[]' or what command line arguments are will help you :)

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.