java


java.lang.NoSuchMethodException: java.io.File.<init>()


I have used the code in Read all files in a folder. But when I try to implement the code, it gives me an error - java.lang.NoSuchMethodException: java.io.File.()
Stack Trace:
java.lang.NoSuchMethodException: java.io.File.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.getDeclaredConstructor(Class.java:2178)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:105)
at
org.springframework.web.method.annotation.ModelAttributeMethodProcessor.createAttribute(ModelAttributeMethodProcessor.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.createAttribute(ServletModelAttributeMethodProcessor.java:81)
at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:104)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:79)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:157)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:124)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:683)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1720)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1679)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
I have searched for long.. Most of answers were about setting up a default constructor. But in my case, the file doesnt have a default constructor. I may be looking at this completely wrong.. So here's hoping some one can help me out..
Thanks in advance :)
Code:
#RequestMapping(value="/retrieve", method=RequestMethod.POST)
public ArrayList<String> listFiles() {
ArrayList<String> listOfFiles =new ArrayList<String>() ;
File folder = new File("E:/uploadedFiles/");
File[] files = folder.listFiles();
for (File file : files) {
if (file.isFile()) {
System.out.println(file.getName());
listOfFiles.add(file.getName());
}
}
return listOfFiles;
}

Related Links

How to schedule a java code having messageArrived method of MqttCallback
Java: How to extract date from the string
Update one document by _id (Invalid BSON field name _id)
How to add BODY VALUES in REST Mock WebService in SoapUi with response?
Add another image programmatically and choose position
How can i communicate between HTML and Java in xcrosswalk?(Android)
Static method in the non static context
Android code for notifications
External Typeface in ExpandableList
error in sending SMTP mail in java
Casting issue when trying to create a HeatMap using Google API on android studio
Spring boot - JPA Hibernate - Mysql UTF8 Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column
ORC stripe size inconsistency across stripes in a spark generated ORC file
android studio error builder (android.content.context) in builder cannot be applied to (anonymous.android.view.view.onclicklistener)
Android socket that controls GPIO
Code is throwing an IndexOutOfBoundsException? [duplicate]

Categories

HOME
cakephp
omnet++
magnific-popup
image-processing
fluentd
tesseract
spring-cloud-stream
rubygems
installshield
mvvmcross
fancybox
synchronization
basic
node-pdfkit
floating-action-button
apache-cayenne
hex-editors
ibm-odm
visual-studio-cordova
decimal
designer
lombok
worldwind
dosgi
opentracing
finite-automata
apache-metamodel
database-replication
samoa
contextmenu
google-search-api
mustache.php
realex-payments-api
java-7
emgucv
opennlp
semantic-analysis
lightswitch-2013
fabric8
google-rich-snippets
binary-data
semantic-versioning
fog
framemaker
protovis
restlet
abstract-class
hilbert-curve
jna
fedex
ncalc
ruby-on-rails-3.1
node-sass
angular2-meteor
avconv
dotcover
outlook-2013
upstart
multipeer-connectivity
rails-routing
yii2-extension
knockout-components
dtexec
pillow
jspdf-autotable
dynamics-sl
ableton-live
gridpane
skobbler-maps
paypal-express
autorest
fputcsv
pickadate
xpath-1.0
associative-array
msys
comobject
security-testing
browser-bugs
arcanist
p2
streambase
javafx-webengine
nsbutton
xcode-6.2
titanium-modules
openexr
eol
rebol3
hippomocks
monomac
terminal-services
sitemesh
spring-io
odata4j
ril
excel-2003
back-stack
wsdl-2.0
bitsharp
dice
postgresql-performance
punbb
ecl
mongomapper
html-input
w3wp.exe
gamma
jquery-ui-droppable
database-management
sef
ti-dsp
eqatec
lzh

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App