Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2011
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement