示例#1
0
 private static void write() throws Exception {
   SinaTopFetcher f = new SinaTopFetcher();
   List<TopDatum> list = SinaTopFetcher.parse(f.exec(f.getUrl()));
   for (TopDatum d : list) {
     DataStorage.get().write(d);
   }
 }
示例#2
0
 public void load(Set<Symbol> symbols) {
   File[] allFiles = null;
   if (symbols == null || symbols.isEmpty()) {
     File dir = new File(DATA_DIR);
     allFiles = dir.listFiles();
   } else {
     List<File> files = new ArrayList();
     for (Symbol s : symbols) {
       File f = findFile(s);
       if (f == null) {
         logger.log(
             Level.WARNING,
             "{0}: not found the file {1} to load",
             new Object[] {s, f.getAbsolutePath()});
         continue;
       }
       files.add(f);
     }
     allFiles = files.toArray(new File[0]);
   }
   for (File f : allFiles) {
     try {
       List<HistPriceDatum> data = loadHistPriceData(f);
       DataStorage.get().write(data);
     } catch (Exception ex) {
       logger.log(
           Level.WARNING,
           "Failed to load all hist price data into DB for file: " + f.getName(),
           ex);
     }
   }
 }