Here you can find the source of saveTemporaryTermFile(File tempLocation, String word, Collection
Parameter | Description |
---|---|
tempLocation | the temp location |
word | the word |
termList | the term list |
Parameter | Description |
---|---|
IOException | Signals that an I/O exception has occurred. |
public static void saveTemporaryTermFile(File tempLocation, String word, Collection<String> termList) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Arrays; import java.util.Collection; public class Main { /**/* ww w .j av a 2 s . co m*/ * Save temporary term file. * * @param tempLocation the temp location * @param word the word * @param termList the term list * @throws IOException Signals that an I/O exception has occurred. */ public static void saveTemporaryTermFile(File tempLocation, String word, Collection<String> termList) throws IOException { if (word == null) return; // if windows OS, check for some speccial files if (System.getProperty("os.name").toLowerCase().startsWith("win")) { if (Arrays.asList("con", "prn").contains(word)) return; } if (!tempLocation.exists()) tempLocation.mkdirs(); File f = new File(tempLocation, word); BufferedWriter w = new BufferedWriter(new FileWriter(f, true)); for (String t : termList) { w.write(t + "\n"); } w.close(); } }