This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java.lang.ClassCastException  RSS feed

 
Awet Haddis
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Background: I am testing a class that will allow a user to upload data. I am using the Apache Commons FileUpload library.




I believe the compiler is having a problem with this statement:



Is there a way to specify the path to a FileItem so I don't have to cast a file as a FileItem? Thanks in advance.
 
Paul Clapham
Sheriff
Posts: 22471
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Awet Haddis wrote:Is there a way to specify the path to a FileItem so I don't have to cast a file as a FileItem? Thanks in advance.


Well, no you can't take just anything and cast it to a FileItem. If you want to simulate what the file upload would have produced, you're going to have to produce a mock version of FileItem and have it wrap your File, or something like that.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!