我正在编写一个网络程序;当我按下用户本地计算机上的按钮(很可能在下载文件夹中)时,应该保存客户端列表。现在我的桌面上保存文件的绝对路径已经写好了,如何更改该路径,使其对任何用户通用?
File file = new File("C:\\Users\\Andrew\\Desktop\\client_data.txt");
try (BufferedWriter writer = new BufferedWriter
(new OutputStreamWriter
(new FileOutputStream(file), StandardCharsets.UTF_8))) {
List<Client> list = (List<Client>) clientRepository.findAll();
for (int i = 0; i < list.size(); i++) {
writer.write(list.get(i).getId() + " " + list.get(i).getName() + " (" + list.get(i).getClStatus() + ") " + list.get(i).getGeneralNum() + ", " + list.get(i).getExtraNum1() + ", " + list.get(i).getExtraNum2() + '\n');
}...