Interfaces in Java cannot be instantiated, but it is possible to use a usage like this:
list<fileitem> items =upload.parserequest (Request); Iterator<FileItem> iter =Items.iterator (); while(Iter.hasnext ()) {Fileitem Item=Iter.next ();File file=NewFile ("D:\\b.pdf"); if(!file.exists ()) { Try{file.createnewfile (); } Catch(IOException e) {e.printstacktrace (); }} bufferedoutputstream Bos=NewBufferedoutputstream (Newfileoutputstream (file));Bufferedinputstream bfis=NewBufferedinputstream (Item.getinputstream ()); byteb[]=New byte[2048]; intRead=bfis.read (b,0,2048); while(Read!=-1) { Bos.write (b,0, read); Read=bfis.read (b,0,2048); } bfis.close (); Bos.flush (); Bos.close ();
Mainly look at these two lines:
list<fileitem> items = upload.parserequest (request);
Iterator<fileitem> iter = Items.iterator ();
Go to the list to find source
List is the interface is not implemented, to find a implementation of the list of the class (ArrayList can)
You can see that a ITR is actually returned:
ITR is defined in the following:
A private class that implements the iterator interface. It's been clear.
Java Interface Variable issues