private static void writeTextFile(Path path){
         BufferedWriter bufferWriter=null;
        try{
           //apertura del stream. StandardOpenOption.CREATE->si el fichero no existe se crea
            bufferWriter=Files.newBufferedWriter(path, 
                    java.nio.charset.StandardCharsets.UTF_8, java.nio.file.StandardOpenOption.CREATE);
            for (int i=0;i<Data.COD.length;i++){
                bufferWriter.write(Data.COD[i]+";"+Data.DESC[i]+";"+Data.STOCK[i]+";"+Data.PRICE[i]);
                bufferWriter.newLine();
            }
            System.out.println("Escritura fichero "+path.getFileName().toString()+ " finalizada");
            readTextFile(path);
            
        } catch (IOException ex) {
            System.err.println("I/O Error: "+ex);
        }finally{
            //Se cierra el stream y se liberan los recursos de sistema asociados a él.
             if (bufferWriter!=null) 
                 try {
                    bufferWriter.close();
                 } catch (IOException ex) {
                    System.err.println("I/O Error: "+ex);
                }
        }
     }