//static { //init(); // } /** * Inits the. */ public static void init() { // DEBUG = false; // INFO = false; // WARN = false; // ERROR = false; if (initialized) { return; } DEBUG = (LOGCAT_LEVEL <= LOG_LEVEL_DEBUG); INFO = (LOGCAT_LEVEL <= LOG_LEVEL_INFO); WARN = (LOGCAT_LEVEL <= LOG_LEVEL_WARN); ERROR = (LOGCAT_LEVEL <= LOG_LEVEL_ERROR); try { Java.IO.File sdRoot = getSDRootFile(); if (sdRoot != null) { Java.IO.File logFile = new Java.IO.File(sdRoot, LOG_FILE_NAME); if (!logFile.Exists()) { logFile.CreateNewFile(); } Log.Debug(LOG_TAG_STRING, TAG + " : Log to file : " + logFile); if (logStream != null) { logStream.Close(); } FileStream file = new FileStream(logFile.Path, FileMode.Open); logStream = new PrintStream(file, true); initialized = true; } logFileChannel = getFileLock(); } catch (Java.Lang.Exception e) { Log.Error(LOG_TAG_STRING, "init log stream failed", e); } }
public override void OnCompleted() { base.OnCompleted(); OutputStream outputStream = null; PrintStream stream = null; try { outputStream = new FileOutputStream("../wiki/ImageDatabaseSummary.wiki", false); stream = new PrintStream(outputStream, false); WriteOutput(stream); stream.Flush(); } catch (IOException e) { Sharpen.Runtime.PrintStackTrace(e); } finally { if (stream != null) { stream.Close(); } if (outputStream != null) { try { outputStream.Close(); } catch (IOException e) { Sharpen.Runtime.PrintStackTrace(e); } } } }
private static void ProcessFile(File effDocFile, File outFile) { if (!effDocFile.exists()) { throw new RuntimeException("file '" + effDocFile.GetAbsolutePath() + "' does not exist"); } OutputStream os; try { os = new FileOutputStream(outFile); } catch (FileNotFoundException e) { throw new RuntimeException(e); } os = new SimpleAsciiOutputStream(os); PrintStream ps; try { ps = new PrintStream(os, true, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } outputLicenseHeader(ps); Type genClass = typeof(ExcelFileFormatDocFunctionExtractor); ps.println("# Created by (" + genClass.Name + ")"); // identify the source file ps.print("# from source file '" + SOURCE_DOC_FILE_NAME + "'"); ps.println(" (size=" + effDocFile.Length + ", md5=" + GetFileMD5(effDocFile) + ")"); ps.println("#"); ps.println("#Columns: (index, name, minParams, maxParams, returnClass, paramClasses, isVolatile, hasFootnote )"); ps.println(""); try { ZipFile zf = new ZipFile(effDocFile); InputStream is1 = zf.GetInputStream(zf.GetEntry("content.xml")); extractFunctionData(new FunctionDataCollector(ps), is1); zf.Close(); } catch (ZipException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } ps.Close(); String canonicalOutputFileName; try { canonicalOutputFileName = outFile.GetCanonicalPath(); } catch (IOException e) { throw new RuntimeException(e); } Console.WriteLine("Successfully output to '" + canonicalOutputFileName + "'"); }