Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Am trying to Upload File on server its been uploaded Succesfully but when am trying to download its showing file not found

Below is my code

String strurl = 
"http://10.94.162.15:9080/swmng/FileUploads/Software/Approval/"+filename+"/
FILE_LIST";
System.out.println("strurl is-=------------------------------------"+strurl);
try{
  XMLParser parser = new XMLParser();         
  arrFileName = parser.getAllFileNames(strurl); 

  for(int i=0; i< arrFileName.length; i++)
    {
                        file = arrFileName[i];
                        System.out.println("file is------------------------ 
"+file);
                        filename=filename.replaceAll("%20", "");
                        if(file!=null && !(file.equalsIgnoreCase("")))
                        {
                            flag = true;
                            if(role==0){
                            hyperlinks +="<tr><td align='center'> 
<b>"+count+". </b> <a 

href='http://10.94.162.15:9080/swmng/FileUploads/Software/Approval/"
+filename+"@"+file+"'>"+file+"</a></td><td><a 

onclick=\"deleteFile('http://10.94.162.15:9080/swmng/FileUploads/Software/
Approval/"+filename.replaceAll("%20", "")+"@"+file+"/DELETE_FILE')\" href='#' 
>Delete</a></td></tr>";
                               System.out.println("hyperlinks---------------- 
----"+hyperlinks);
                             }
                            else
                            {
                                hyperlinks +="<tr><td align='center'> 
<b>"+count+". </b> <a 





href='http://10.94.162.15:9080/swmng/FileUploads/Software/Approval/"+
filename+"@"+file+"'>"+file+"</a></td></tr>";
                            }
                            count++;

                        }

                    }


Am passing strurl to method getAllFileNames(strurl)  the code for this method 
is 


public String[] getAllFileNames(String fileName) { 
    String[] arrFilename = null;
    try { 
        System.out.println("inside 
getAllFileNames==============================="+fileName);
                    DocumentBuilderFactory dbf = 
DocumentBuilderFactory.newInstance(); 
                    DocumentBuilder db = dbf.newDocumentBuilder(); 
                    fileName = fileName.replaceAll(" ", "%20");
                    URL url = new URL(fileName);

        String inputLine;
            Document doc = db.parse(url.openStream()); 
            System.out.println("inside getAllFileNames 
url==============================="+url);

                    XPathFactory xpfactory = XPathFactory.newInstance();
                    XPath path = xpfactory.newXPath();

                    int totalActiveNodes = ((Number) 
path.evaluate("count(/root/fileName)", doc, 
XPathConstants.NUMBER)).intValue();
                    arrFilename = new String[totalActiveNodes+1];
                    for (int i = 1; i <= totalActiveNodes; i++)
                    {
                        arrFilename[i] = (path.evaluate("/root/fileName[" + i 
+ "]", doc));
                        System.out.println("arrFilename---------------------- 
------"+arrFilename[i]);
                    }

    } catch (Exception e) { 
        System.out.println(e);`
  At this line Document doc = db.parse(url.openStream()); 

The compiler throwing FileNotFound but at given location my file is been stored. Am giving location to store file is

 //Tomcat//apache-tomcat-8.5.16//webapps//swmng//FileUploads//Software//Approval//'

File is been uploaded at the above location but when trying to download its failing.Please help me in this. I have tried by changing the path of the file which am uploading but still it didn't work out every time am facing only one issue file not found.but if i check manually the file is present in that location.

What exactly i need to do here? The location is correct or do i need to change the location for uploading even? If the location is same how should I place the location of file where its getting uploaded in the place of downloading and how to place as its getting uploading in tomcat directory? so how should i put that location in downloading path?

Comments