Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.FileInputStream;
  3. import java.io.FileNotFoundException;
  4. import java.io.FileReader;
  5. import java.io.IOException;
  6. import java.util.StringTokenizer;
  7. import java.io.*;
  8.  
  9. public class PPJ27{
  10. public static void main(String[] args){
  11.  
  12. String line2[] = new String[8];
  13. Wiadomosc tab[] = new Wiadomosc[500];
  14. String line = " ";
  15. String line3 = " ";
  16.  
  17. try{
  18. BufferedReader br = new BufferedReader(new FileReader(new File("C:\\Users\\s18967\\Desktop\\serverLog.txt")));
  19.  
  20. int i=0;
  21. int j=0;
  22.  
  23. while( (line=br.readLine()) !=null){
  24.  
  25. line=br.readLine();
  26. line3=line.substring(0,(line.indexOf(">")));
  27.  
  28.  
  29. StringTokenizer st = new StringTokenizer(line3);
  30.  
  31. while(st.hasMoreTokens()){
  32.  
  33. if(i==1){
  34. StringTokenizer st1 = new StringTokenizer(st.nextToken());
  35.  
  36. while(st1.hasMoreTokens()){
  37.  
  38. line2[i]=st1.nextToken();
  39.  
  40. i++;
  41. }
  42. line2[i]=st.nextToken();
  43.  
  44. }
  45.  
  46. i++;
  47.  
  48. }
  49. i=0;
  50.  
  51. tab[j] = new Wiadomosc(Integer.parseInt(line2[1]) , Integer.parseInt(line2[2]) , Integer.parseInt(line2[3]) , line2[4], line2[5], line2[6], line2[7]);
  52. j++;
  53. }
  54.  
  55.  
  56. /* s.indexOf(">") -> indeks tego >
  57. s.substring(0, i)
  58. s.substring(i+1)
  59. */
  60.  
  61.  
  62. }catch (IOException exception){
  63. exception.printStackTrace();
  64. }
  65. }
  66. }
  67. //=======Zadanie 1======================================
  68. class Wiadomosc{
  69.  
  70. int dzien, miesiac, rok;
  71. String godzina, user, ip, tekst;
  72.  
  73. Wiadomosc(int dzien, int miesiac, int rok, String godzina, String user, String ip, String tekst){
  74. this.dzien = dzien;
  75. this.miesiac = miesiac;
  76. this.rok = rok;
  77. this.godzina = godzina;
  78. this.user = user;
  79. this.ip = ip;
  80. this.tekst = tekst;
  81. }
  82.  
  83. public String ToString(){
  84. return super.toString();
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement