Java Path File Write nio write(Object obj, String filePath)

Here you can find the source of write(Object obj, String filePath)

Description

write

License

Open Source License

Declaration

public static void write(Object obj, String filePath) throws IOException 

Method Source Code


//package com.java2s;
import java.io.IOException;

import java.io.ObjectOutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
    public static void write(Object obj, String filePath) throws IOException {
        Path path = Paths.get(filePath);
        try (ObjectOutputStream output = new ObjectOutputStream(Files.newOutputStream(path))) {
            output.writeObject(obj);/*from  w  w  w  .  j a  v  a 2s .c o  m*/
        }
    }
}

Related

  1. saveTo(String path, InputStream in)
  2. saveToFile(String path, byte[] text)
  3. setPosixPermissions(String path, boolean ownerRead, boolean ownerWrite, boolean ownerExecute, boolean groupRead, boolean groupWrite, boolean groupExecute, boolean othersRead, boolean othersWrite, boolean othersExecute)
  4. srcImageToSavePath(String src, Path saveFolder)
  5. write(List list, String outputPath)
  6. write(Path p)
  7. write(Path p, String s)
  8. write(Path path, String string)
  9. writeAudio(String source, String writePath)