How can I get relative path of the folders in my android project?

前端 未结 8 1685
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-08 19:16

How can I get the relative path of the folders in my project using code?

I\'ve created a new folder in my project and I want its relative path so no matter where the

8条回答
  •  隐瞒了意图╮
    2020-12-08 19:55

    Generally we want to add images, txt, doc and etc files inside our Java project and specific folder such as /images. I found in search that in JAVA, we can get path from Root to folder which we specify as,

    String myStorageFolder= "/images"; // this is folder name in where I want to store files.
    
    String getImageFolderPath= request.getServletContext().getRealPath(myStorageFolder);
    

    Here, request is object of HttpServletRequest. It will get the whole path from Root to /images folder. You will get output like,

    C:\Users\STARK\Workspaces\MyEclipse.metadata.me_tcat7\webapps\JavaProject\images

提交回复
热议问题