I have question about how to create file and append it.
what i have is
String getDate = "2020-04-02"
for name file.
so my file will create every day if the date different one so my format for save file is
2020-04-02.text and for tomorrow my data will save in 2020-04-03.
after that my input data is
String savefile ="aaaa|bbbb|2020-04-02T08:18:35.146"
my question is how to create file and append my data to fix save file ?
i have try using
System.out.println("savelocation: " + paths);
Files.write(Paths.get(paths), savefile.getBytes(StandardCharsets.UTF_8),
StandardOpenOption.CREATE, StandardOpenOption.APPEND);
but i got error like this
java.nio.file.NoSuchFileException: /home/ec2-user/saveFile/EUR/USD|2020-04-02.txt
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434)
my expected code is : 1. Check file path it is exist or not if it is exist append data 2. if file path it is not exist create new file and write new data
regards
Fuad