KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > about > ConfigurationLogErrorLogSection


1 /*******************************************************************************
2  * Copyright (c) 2003, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.about;
12
13 import java.io.File JavaDoc;
14 import java.io.FileInputStream JavaDoc;
15 import java.io.IOException JavaDoc;
16 import java.io.InputStreamReader JavaDoc;
17 import java.io.PrintWriter JavaDoc;
18 import java.io.Reader JavaDoc;
19
20 import org.eclipse.core.runtime.Platform;
21 import org.eclipse.ui.about.ISystemSummarySection;
22
23 /**
24  * This class puts the content of the platform's error log into the system
25  * summary dialog.
26  *
27  * @since 3.0
28  */

29 public class ConfigurationLogErrorLogSection implements ISystemSummarySection {
30
31     /**
32      * Appends the contents of the .log file
33      *
34      * @see org.eclipse.ui.about.ISystemSummarySection#write(java.io.PrintWriter)
35      */

36     public void write(PrintWriter JavaDoc writer) {
37         File JavaDoc log = new File JavaDoc(Platform.getLogFileLocation().toOSString());
38         if (log.exists()) {
39             Reader JavaDoc reader = null;
40             try {
41                 reader = new InputStreamReader JavaDoc(new FileInputStream JavaDoc(log),
42                         "UTF-8"); //$NON-NLS-1$
43
char[] chars = new char[8192];
44                 while (true) {
45                     int read = reader.read(chars);
46                     if (read <= 0)
47                         break;
48                     writer.write(chars, 0, read);
49                 }
50             } catch (IOException JavaDoc e) {
51                 writer.println("Error reading .log file"); //$NON-NLS-1$
52
} finally {
53                 try {
54                     reader.close();
55                 } catch (IOException JavaDoc e) {
56                     // do nothing
57
}
58             }
59         }
60     }
61 }
62
Popular Tags