Page 1 of 1

About Question enthuware.ocpjp.v11.2.3415 :

Posted: Wed Oct 11, 2023 3:33 pm
by powerofviva
But the user did not validate the input right?
so number 2 is also correct? isnt it?

Re: About Question enthuware.ocpjp.v11.2.3415 :

Posted: Thu Oct 12, 2023 11:16 am
by admin
There is nothing to validate in the input. The input is a file name and if the file name is incorrect, there will be an exception as indicated by the throws clause.
The real issue in the code is opening unlimited number of files.

Re: About Question enthuware.ocpjp.v11.2.3415 :

Posted: Thu Oct 12, 2023 2:41 pm
by powerofviva
Ok got it now,
thanks

Re: About Question enthuware.ocpjp.v11.2.3415 :

Posted: Fri May 03, 2024 7:19 am
by adrianjara
About this code:

Code: Select all

public void processUploads(String listOfFilesFile) throws IOException{
    File f = new File(listOfFilesFile);

The name of the argument refers to the fact that the entry is a list, that is, it contains several file names separated by commas.

Is that to confuse? How do we know that only the name of a file arrives there?

Then, there is no File constructor that receives several file names separated by commas, which is why the input would have to be previously validated to verify the type of value in the argument that arrives,

That's why my answer would also be No. 2.

The security part is very broad and extensive, but the answers to why one or the other is selected is not clear.

Could you expand the explanation further?

Re: About Question enthuware.ocpjp.v11.2.3415 :

Posted: Fri May 03, 2024 7:58 am
by admin
The name listOfFilesFile ends with 'File', so it is quite clear that it will get a String containing the name of the file that contains a list of files. Also, the parameter type is just String and not List<String>.
Further, File f = new File(listOfFilesFile); clearly implies that listOfFilesFile is a path to a file.