testdev/ite/test/com.nokia.testfw.launch.test/src/com/nokia/testfw/launch/monitor/LogFileWriter.java
changeset 1 96906a986c3b
equal deleted inserted replaced
0:f1112f777ce9 1:96906a986c3b
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 package com.nokia.testfw.launch.monitor;
       
    18 
       
    19 import java.io.BufferedWriter;
       
    20 import java.io.FileWriter;
       
    21 import java.io.IOException;
       
    22 import java.io.PrintWriter;
       
    23 
       
    24 /**
       
    25  * @author xiaoma
       
    26  * This is a test class used to continue write content to a file
       
    27  */
       
    28 public class LogFileWriter implements Runnable {
       
    29 
       
    30 	PrintWriter out;
       
    31 	int times;
       
    32 	public LogFileWriter(String file, int times) throws IOException {
       
    33 		
       
    34 		out = new PrintWriter(new BufferedWriter(
       
    35 				   new FileWriter(file, false)));
       
    36 		this.times = times;
       
    37 	}
       
    38 	
       
    39 	/* (non-Javadoc)
       
    40 	 * @see java.lang.Runnable#run()
       
    41 	 */
       
    42 	public void run() {
       
    43 		 
       
    44 	    out.println("oldtest");
       
    45 	    out.flush();
       
    46 		try {
       
    47 			Thread.sleep(1000);
       
    48 		} catch (InterruptedException e1) {
       
    49 			// TODO Auto-generated catch block
       
    50 			e1.printStackTrace();
       
    51 		}
       
    52 
       
    53 	    int time = 0;	
       
    54 	    System.err.println("write start to file");
       
    55 		while (time < times) {
       
    56 		    try {
       
    57 		    	time++;
       
    58 				System.err.println("write to log");
       
    59 			    out.println("test" + time);
       
    60 			    out.flush();
       
    61 				Thread.sleep(1000);
       
    62 			} catch (InterruptedException e) {
       
    63 				// TODO Auto-generated catch block
       
    64 				e.printStackTrace();
       
    65 			}
       
    66 	
       
    67 		}
       
    68 		System.err.println("write log finished");
       
    69 		out.close();
       
    70 		out = null;
       
    71 		
       
    72 	}
       
    73 
       
    74 }