code: public static void writeFile(VirtualFile virtualFile, byte[] bytes) throws IOException {
          final File file = virtualFile.getPhysicalFile();
          file.getParentFile().mkdirs();
          final FileOutputStream fos = new FileOutputStream(file);
          try {
              fos.write(bytes);
              fos.close();
          } finally {
              safeClose(fos);
          }
      }
docs: Write the given bytes to the given virtual file, replacing its current contents (if any) or creating a new file if
  one does not exist.
  
  @param virtualFile the virtual file to write
  @param bytes       the bytes
  @throws IOException if an error occurs