Advertisement
Adrianolls

Untitled

Jan 17th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. @Override
  2. public void run() {
  3. System.out.println("IpController Started");
  4. while (true) {
  5. proccessLogFile = proccessLine();
  6. if (proccessLogFile) {
  7. ipacc = InfoDB.ListarIpUserId(Integer.valueOf(this.prop.getProperty("userid")));
  8. if (null == ipacc) {
  9. ipacc = new IpAccountModel();
  10. }
  11. ipacc.setUserid(Integer.valueOf(this.prop.getProperty("userid")));
  12. ipacc.setAccount(Integer.valueOf(this.prop.getProperty("userid")));
  13. ipacc.setIp(this.prop.getProperty("peer"));
  14. InfoDB.salvarOuAtualizar(ipacc);
  15. }
  16. }
  17.  
  18. }
  19.  
  20. private void startupController() {
  21. try {
  22. this.file_reader = new FileReader(this.settings.getPvp_logs());
  23. this.br = new BufferedReader(this.file_reader);
  24. // End of File
  25. while ((brline = br.readLine()) != null) {
  26. }
  27. Thread.sleep(1000L);
  28. } catch (FileNotFoundException ex) {
  29. ThreadException(ex);
  30. } catch (IOException ex) {
  31. ThreadException(ex);
  32. } catch (InterruptedException ex) {
  33. ThreadException(ex);
  34. }
  35. }
  36.  
  37. private boolean proccessLine() {
  38. try {
  39. brline = br.readLine();
  40. } catch (IOException ex) {
  41. ThreadException(ex);
  42. }
  43. if (brline == null) {
  44. try {
  45. Thread.sleep(1000L);
  46. return false;
  47. } catch (InterruptedException ex) {
  48. ThreadException(ex);
  49. }
  50. } else {
  51. brline = brline.replaceAll(" ", "\n");
  52. brline = brline.replaceAll(":", "\n");
  53. if (brline.contains("login")) {
  54. try {
  55. prop.load(new StringReader(brline));
  56. } catch (IOException ex) {
  57. ThreadException(ex);
  58. }
  59. return true;
  60. }
  61. }
  62. return false;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement