Convert MultipartFile to File on Spring

Convert MultipartFile to File on Spring:

package com.yamicode.file.utils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import org.springframework.web.multipart.MultipartFile;

@Component
public class FilesUtil {

  private static final String path=File.separator+"yamicode"+File.separator;

  public static File moveAndStoreFile(MultipartFile file, String name) throws IOException {
    String url = path+name;
    File fileToSave = new File(url);
    fileToSave.createNewFile();
    FileOutputStream fos = new FileOutputStream(fileToSave); 
    fos.write(file.getBytes());
    fos.close();
    return fileToSave;
  }
}