Bom dia pessoal. Tenho uma aplicação java desktop(javaFX)que salva alguns dados de configuração em um arquivo CSV. O jar da mesma funciona perfeitamente tanto no OSX quanto no Linux, porém não no Windows, pelo erro acredito que eu esteja parametrizando de forma incorreta o diretorio, mas não me lembro de outra maneira e nem encontrei(ja tem uns 8 anos que não colocava a mão no Windows).
Segue abaixo código do trecho:
Path ARQUIVO_SAIDA = Paths.get("dados.csv");
private void salvaDados() {
StringBuffer sb = new StringBuffer();
for (Configuracao c : contas) {
String linha = criaLinha(c);
sb.append(linha);
sb.append(System.getProperty("line.separator"));
}
try {
Files.delete(ARQUIVO_SAIDA);
Files.write(ARQUIVO_SAIDA, sb.toString().getBytes());
} catch (IOException e) {
e.printStackTrace();
System.exit(0);
}
}
também tentei utilizar o seguinte caminho(no caso acima o arquivo está no mesmo diretorio que o jar)
private static final Path ARQUIVO_SAIDA = Paths.get("C:\\PastaSistema\\dados.csv");
E retorna o seguinte erro:
java.nio.file.AccessDeniedException: dados.csv at
sun.nio.fs.WindowsException.translateToIOException(Unknown Source)atsun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)atsun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)atsun.nio.fs.WindowsFileSystemProvider.newByteChannel(Unknown Source)atjava.nio.file.spi.FileSystemProvider.newOutputStream(Unknown Source)atjava.nio.file.Files.newOutputStream(Unknown Source)atjava.nio.file.Files.write(Unknown Source)at br.com.denisg.integradorifood.impl.ConfiguracaoServiceImpl.salvaDados (ConfiguracaoServiceImpl.java:81) atbr.com.denisg.integradorifood.impl.ConfiguracaoServiceImpl.atualizar( ConfiguracaoServiceImpl.java:51)at br.com.denisg.integradorifood.controller.ConfiguracaoController.atual izar(ConfiguracaoController.java:67) atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)atsun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)atsun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)atjava.lang.reflect.Method.invoke(Unknown Source)atsun.reflect.misc.Trampoline.invoke(Unknown Source)atsun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)atsun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)atjava.lang.reflect.Method.invoke(Unknown Source)atsun.reflect.misc.MethodUtil.invoke(Unknown Source)at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1771)at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader .java:1657)atcom.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Comp ositeEventHandler.java:86)atcom.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventH andlerManager.java:238)atcom.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventH andlerManager.java:191)atcom.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(C ompositeEventDispatcher.java:59)atcom.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDis patcher.java:58)atcom.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispat chChainImpl.java:114)atcom.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDis patcher.java:56)atcom.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispat chChainImpl.java:114)atcom.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDis patcher.java:56)atcom.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispat chChainImpl.java:114)atcom.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)atcom.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)atjavafx.event.Event.fireEvent(Event.java:198)atjavafx.scene.Node.fireEvent(Node.java:8411)atjavafx.scene.control.Button.fire(Button.java:185)atcom.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(Bu ttonBehavior.java:182)at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorS kinBase.java:96) at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorS kinBase.java:89) at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.h andleBubblingEvent(CompositeEventHandler.java:218) atcom.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Comp ositeEventHandler.java:80)atcom.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventH andlerManager.java:238)atcom.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventH andlerManager.java:191)atcom.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(C ompositeEventDispatcher.java:59)atcom.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDis patcher.java:58)atcom.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispat chChainImpl.java:114)atcom.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDis patcher.java:56)atcom.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispat chChainImpl.java:114)atcom.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDis patcher.java:56)atcom.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispat chChainImpl.java:114)atcom.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)atcom.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)atjavafx.event.Event.fireEvent(Event.java:198)at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485) atjavafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)atjava.security.AccessController.doPrivileged(Native Method)at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEve nt$353(GlassViewEventHandler.java:432) atcom.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Quantum Toolkit.java:389)atcom.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Glas sViewEventHandler.java:431)atcom.sun.glass.ui.View.handleMouseEvent(View.java:555)atcom.sun.glass.ui.View.notifyMouse(View.java:937)atcom.sun.glass.ui.win.WinApplication._runLoop(Native Method)at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.ja va:177) atjava.lang.Thread.run(Unknown Source)
Ja dei permissões nas pastas até com o usuarios Todos e permissão total. Acredito que seja um erro bem idiota.
Vlww galera