0

I have a desktop application developed in Java. This application write data in a .csv.

In my application, I have the possibility to access to the history. If someone have opened the history, the application could not write in it.

My problem is that I do not know how to check if the history is opened or not in my application. I am thinking in different options which will solve my problem and I have these ones:

-Develop an xlsm file which copy data from the history and reference to it in my button.

-Access to history in read-only mode (that will be the better option, but I do not know how to do this)

-Disable the button and not offer this option.

Runtime.getRuntime().exec("cmd /c start  P:\\\"directory\\\\projects\\\\2019\\\\GesPlanCam\\\\Results" + LocalDate.now().getMonthValue() + "-" + LocalDate.now().getYear() + ".csv");

As you can see, I access to the file with my cmd and I do an monthly history.

I thaught the better option was to put an argument in my line to open it in read-only mode, but I did not find anything in sources.

Actually, I think the best option to implement is to develop the xlsm file I said before because I do not find any information about how to develop the other ideas, but I know that xlsm file is not efficent and I want to avoid this solution.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Adrián
  • 1
  • 4
  • There is an answer written in PowerShell. That can be put into a .ps1 file and run from a cmd.exe shell. https://stackoverflow.com/questions/24992681/powershell-check-if-a-file-is-locked – lit Mar 08 '19 at 14:08
  • 1) This problem has nothing to do with Swing (even if it uses a Swing GUI). Refrain from adding tags not relevant to the problem at hand. 2) See also [When Runtime.exec() won't](http://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html) for many good tips on creating and handling a process correctly. Then ignore it refers to `exec` and use a `ProcessBuilder` to create the process. Also break a `String arg` into `String[] args` to account for things like paths containing space characters. – Andrew Thompson Mar 08 '19 at 14:36

0 Answers0