Java Path File Name nio saveNamesToFile(Map namesMap, Path namesFile)

Here you can find the source of saveNamesToFile(Map namesMap, Path namesFile)

Description

save Names To File

License

Open Source License

Declaration

public static File saveNamesToFile(Map<String, Integer> namesMap, Path namesFile) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;
import java.nio.file.Path;
import java.util.*;

public class Main {
    public static File saveNamesToFile(Map<String, Integer> namesMap, Path namesFile) throws IOException {
        final File names = namesFile.toFile();

        try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(names))) {
            for (Map.Entry<String, Integer> entry : namesMap.entrySet()) {
                bufferedWriter.write(String.valueOf(entry.getValue()));
                bufferedWriter.write("\t");
                bufferedWriter.write(entry.getKey());
                bufferedWriter.newLine();
            }//from   w w w  .ja  v a 2s  . c  om
        }

        return names;
    }
}

Related

  1. relativizePath(Path relativeTo, String filename)
  2. rename(Path origin, Path destination)
  3. renameFile(Path filePath, String postfix)
  4. renameLogFile(Path original)
  5. saveFileFromByteArray(String filename, String pathDirectory, byte[] data)
  6. saveToFile(String content, String directoryPath, String filename)
  7. shortenFileName(Path file, List dirs)
  8. storeFile(String fileName, InputStream inputStream, Path targetPath)
  9. subDirectoryNames(final Path dir)