Mercurial > hg > LGServices
comparison src/main/java/de/mpiwg/gazetteer/utils/FileManager.java @ 54:a00efd5d9e77
new: adding delete saved table function
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 04 Feb 2016 11:30:46 +0100 |
parents | cf747a960516 |
children | b8ad346e39a0 |
comparison
equal
deleted
inserted
replaced
53:db2088ac1f50 | 54:a00efd5d9e77 |
---|---|
2 | 2 |
3 import java.io.File; | 3 import java.io.File; |
4 import java.io.IOException; | 4 import java.io.IOException; |
5 import java.io.PrintWriter; | 5 import java.io.PrintWriter; |
6 import java.nio.file.Files; | 6 import java.nio.file.Files; |
7 import java.nio.file.Path; | |
7 import java.nio.file.Paths; | 8 import java.nio.file.Paths; |
8 import java.text.DateFormat; | 9 import java.text.DateFormat; |
9 import java.text.SimpleDateFormat; | 10 import java.text.SimpleDateFormat; |
10 import java.util.Date; | 11 import java.util.Date; |
11 import java.util.List; | 12 import java.util.List; |
244 | 245 |
245 byte[] encoded = Files.readAllBytes(Paths.get(absolutePath)); | 246 byte[] encoded = Files.readAllBytes(Paths.get(absolutePath)); |
246 return new String(encoded, "UTF8"); | 247 return new String(encoded, "UTF8"); |
247 | 248 |
248 } | 249 } |
250 | |
251 | |
252 | |
253 protected static void deleteFileFromFileSystemByAbsolutePath(String absolutePath) { | |
254 try{ | |
255 File file = new File(absolutePath); | |
256 | |
257 if(file.delete()){ | |
258 System.out.println(file.getName() + " is deleted!"); | |
259 }else{ | |
260 System.out.println("Delete operation is failed."); | |
261 } | |
262 | |
263 }catch(Exception e){ | |
264 | |
265 e.printStackTrace(); | |
266 | |
267 } | |
268 } | |
269 | |
270 public static void deleteFullTextSearchFileCsv(LGFullTextSearchFile file) throws IOException { | |
271 // csv file is in LGMap/datasets/ | |
272 String absolutePath = PropertiesUtils.getPropValue("lgmap_datasets") + "/" + file.getUserId() + "_" + file.getFileName() + ".csv"; | |
273 | |
274 deleteFileFromFileSystemByAbsolutePath(absolutePath); | |
275 } | |
276 | |
277 | |
278 public static void deleteFullTextSearchFileHtml(LGFullTextSearchFile file) throws IOException { | |
279 // html file is in ftsearch-data/... | |
280 String absolutePath = PropertiesUtils.getPropValue("ftsearch_root") + "/html/" + file.getUserId().toString() + "/" + file.getFileName() + ".html"; | |
281 | |
282 deleteFileFromFileSystemByAbsolutePath(absolutePath); | |
283 } | |
249 | 284 |
250 | 285 |
251 } | 286 } |