0

In my Java app, I generate pdf and save it to a location on user's PC e.g. C:\\Download. However, as various users have different operating systems e.g. Windows or Linux, I think it is good idea to save the generated pdf file to a generic place for all of the operating system. For this situation, should I save it:

1. A generic user directory in the operating system?

2. A fix place e.g. C:\\Download. But in this scene, user may not have write permission in a Company domain.

Or any proper place that is suitable for Linux and Windows?

Jack
  • 1
  • 21
  • 118
  • 236

1 Answers1

1

To avoid any operating system dependencies use the "user.home" property in java :

pdfDirectory = new File (System.getProperty("user.home"),"pdfDir");
  • Generic user directory for all operating systems ✅
  • Current user has access to his home directory ✅
Hajed.Kh
  • 408
  • 3
  • 11