Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

Parsing a log file in Java -


all,

i have log file below content.

request centercord. 2010-12-14 12:42:13.724 [ 6796] **************************** 2010-12-14 12:42:13.724 [ 6796] 1111111111111111 2010-12-14 12:42:13.724 [ 6796]22222222222  response centercord. 2010-12-14 12:42:21.802 [ 5960] 11111111111111 2010-12-14 12:42:21.802 [ 5960]  ffffffffffffffffffffffffffff 2010-12-14 12:42:21.802 [ 5960]  tttttttttttttttttttttttttttt  request centercord. 2010-12-14 12:42:13.724 [ 6796] **************************** 

i need create 2 log files 1 storing request details , other 1 storing response details. how can parse , prepare 2 log files?.

i need below answer.

log 1:  request centercord. 2010-12-14 12:42:13.724 [ 6796] **************************** 2010-12-14 12:42:13.724 [ 6796] 1111111111111111 2010-12-14 12:42:13.724 [ 6796]22222222222  2010-12-14 12:42:13.724 [ 6796] ****************************  log 2:  response centercord. 2010-12-14 12:42:21.802 [ 5960] 11111111111111 2010-12-14 12:42:21.802 [ 5960]  ffffffffffffffffffffffffffff 2010-12-14 12:42:21.802 [ 5960]  tttttttttttttttttttttttttttt 

regards, kanagaraj

here how it:

import java.io.*; import java.util.scanner;  public class test {      public static void main(string[] args) {          try {              printwriter requests = new printwriter("requests.txt");             printwriter responses = new printwriter("responses.txt");             printwriter currentlog = null;              scanner s = new scanner(new file("log.txt"));             while (s.hasnextline()) {                 string line = s.nextline();                 if (line.startswith("request from"))                     currentlog = requests;                 else if (line.startswith("response from"))                     currentlog = responses;                 else if (currentlog != null)                     currentlog.println(line);             }              requests.close();             responses.close();             s.close();         } catch (ioexception ioex) {             // handle exception...         }     } } 

given log.txt

request centercord. 2010-12-14 12:42:13.724 [ 6796] **************************** 2010-12-14 12:42:13.724 [ 6796] 1111111111111111 2010-12-14 12:42:13.724 [ 6796]22222222222  response centercord. 2010-12-14 12:42:21.802 [ 5960] 11111111111111 2010-12-14 12:42:21.802 [ 5960]  ffffffffffffffffffffffffffff 2010-12-14 12:42:21.802 [ 5960]  tttttttttttttttttttttttttttt  request centercord. 2010-12-14 12:42:13.724 [ 6796] **************************** 

it produces, requests.txt

2010-12-14 12:42:13.724 [ 6796] **************************** 2010-12-14 12:42:13.724 [ 6796] 1111111111111111 2010-12-14 12:42:13.724 [ 6796]22222222222  2010-12-14 12:42:13.724 [ 6796] **************************** 

...and responses.txt

2010-12-14 12:42:21.802 [ 5960] 11111111111111 2010-12-14 12:42:21.802 [ 5960]  ffffffffffffffffffffffffffff 2010-12-14 12:42:21.802 [ 5960]  tttttttttttttttttttttttttttt 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -