private static void writeObjectFile(Path path){
         
        ObjectOutputStream dataOut=null;
        try {
            //apertura del stream. StandardOpenOption.CREATE->si el fichero no existe se crea
            dataOut = new ObjectOutputStream(Files.newOutputStream(path, java.nio.file.StandardOpenOption.CREATE));
            for (int i=0; i<Data.COD.length;i++){
                Product product = new Product (Data.COD[i], Data.DESC[i], Data.STOCK[i], Data.PRICE[i]);
                //escritura de objetos (thorws IOException): 
                dataOut.writeObject(product);
            }
         System.out.println("Escritura fichero "+path.getFileName().toString()+ "finalizada");
         readObjectFile(path);
        }catch (IOException ex) {
            System.err.println("Error I/O "+ex);
        }finally{
            //Se cierra el stream y se liberan los recursos de sistema asociados a él.
            if (dataOut!=null)
            try{
                dataOut.close();
            }catch (IOException ex) {
                System.err.println("Error I/O "+ex);
            } 
        }
     }