Previously, my code was developed to fetch the file content from the HTTP URL like "http://storage.googleapis.com/abc". But, requirement just slightly has got changed now and demands that instead of using HTTP URL link, it should need to use file directory location of the server. (i.e., /var/puru/abc
).
So, is there any proper or significant way to do and fulfill the requirement without much-doing changes to my existing code drastically?
I have provided the code sample here, which provide the file URL(baseUrl) that is using http URL actually.
private URL getFileUrl(String fileName) throws MalformedURLException {
try {
Date dateObj = dateFormatter.parse(date);
Calendar cal = Calendar.getInstance();
cal.setTime(dateObj);
return new URL(baseUrl, cal.get(Calendar.YEAR) + "/" + fileName);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
Please suggest, and guide me.