This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 2nd, 2011  |  syntax: None  |  size: 1.36 KB  |  views: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //    @NoTransaction
  2.     public static boolean uploadNewBase(@Required File base, @Required String separator) throws FileNotFoundException, IOException
  3.     {
  4.         LineNumberReader lnr = new LineNumberReader(new FileReader(base));
  5.         lnr.skip(Long.MAX_VALUE);
  6.         int count = lnr.getLineNumber();
  7.  
  8.         if(Tarification.checkAndCharge(Security.getUser().id, 0, count))
  9.         {
  10.             if(separator.isEmpty())
  11.             {
  12.                 separator = ";";
  13.             }
  14.  
  15.             BufferedReader br = new BufferedReader(new FileReader(base));
  16.            
  17.             List<Base> bases = new ArrayList<Base>();
  18.            
  19.             while(br.ready())
  20.             {
  21.                 String readLine = br.readLine();
  22.                 String[] split = readLine.split(separator);
  23.  
  24.                 if(split.length > 1)
  25.                 {
  26.                     String email = split[0], password = split[1];
  27.                     bases.add(new Base(Security.getUser(), email.trim(), password));
  28.                     Base b = new Base(Security.getUser(), email.trim(), password);
  29.                     b.save();
  30.                 }
  31.             }
  32.            
  33.             for(Base b : bases)
  34.             {
  35.                 b.save();
  36.             }
  37.  
  38.             br.close();
  39.             base.delete();
  40.  
  41.             return true;
  42.         }
  43.  
  44.         base.delete();
  45.  
  46.         return false;
  47.     }
clone this paste RAW Paste Data