Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Fetching relative Path of a File in sling servlet

Avatar

Level 1

Hi,

I am trying to read the content of html file present in my local D drive inside slingServlet For e.g I have a file present at D:\\Home\product\demo.html, this path is provided in an excel-sheet I am reading the path from excel-sheet and fetching the content of the file present at that location. But instead of giving full absolute path of file in excel, I want to give relative path of file like this Home\product\demo.html or product\demo.html. I don't want to mention any drive path, since only home\product\demo.html structure is fix drive can be anything. Please suggest if there is any way to skip the drive path in slingservlet.

Thanks in Advance !!

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

This question is not specific to AEM, but a general Java question.

The "File" abstraction of Java allows you to use platform-dependent paths, that means on Windows you can use "D:\Home\...", while on an Unix system you can use /Home/...; so you don't have care about it at all.

Jörg

View solution in original post

2 Replies

Avatar

Correct answer by
Employee Advisor

This question is not specific to AEM, but a general Java question.

The "File" abstraction of Java allows you to use platform-dependent paths, that means on Windows you can use "D:\Home\...", while on an Unix system you can use /Home/...; so you don't have care about it at all.

Jörg