Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.StringTokenizer;
- import java.io.*;
- public class PPJ27{
- public static void main(String[] args){
- String line2[] = new String[8];
- Wiadomosc tab[] = new Wiadomosc[500];
- String line = " ";
- String line3 = " ";
- try{
- BufferedReader br = new BufferedReader(new FileReader(new File("C:\\Users\\s18967\\Desktop\\serverLog.txt")));
- int i=0;
- int j=0;
- while( (line=br.readLine()) !=null){
- line=br.readLine();
- line3=line.substring(0,(line.indexOf(">")));
- StringTokenizer st = new StringTokenizer(line3);
- while(st.hasMoreTokens()){
- if(i==1){
- StringTokenizer st1 = new StringTokenizer(st.nextToken());
- while(st1.hasMoreTokens()){
- line2[i]=st1.nextToken();
- i++;
- }
- line2[i]=st.nextToken();
- }
- i++;
- }
- i=0;
- tab[j] = new Wiadomosc(Integer.parseInt(line2[1]) , Integer.parseInt(line2[2]) , Integer.parseInt(line2[3]) , line2[4], line2[5], line2[6], line2[7]);
- j++;
- }
- /* s.indexOf(">") -> indeks tego >
- s.substring(0, i)
- s.substring(i+1)
- */
- }catch (IOException exception){
- exception.printStackTrace();
- }
- }
- }
- //=======Zadanie 1======================================
- class Wiadomosc{
- int dzien, miesiac, rok;
- String godzina, user, ip, tekst;
- Wiadomosc(int dzien, int miesiac, int rok, String godzina, String user, String ip, String tekst){
- this.dzien = dzien;
- this.miesiac = miesiac;
- this.rok = rok;
- this.godzina = godzina;
- this.user = user;
- this.ip = ip;
- this.tekst = tekst;
- }
- public String ToString(){
- return super.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement