public bool Run() { string code = editor.Document.TextContent; // check if we already have compiled this code before int hashCode = code.GetHashCode(); if (database != null && this.hashCode == hashCode) { return(false); } this.hashCode = hashCode; java.io.StringReader reader = new java.io.StringReader(code); try { java.io.StringWriter writer = new java.io.StringWriter(); try { java.io.PrintWriter log = new java.io.PrintWriter(writer); try { Database db; db = JPortal.run(name, reader, log); if (db != null) { database = db; } } finally { log.flush(); log.close(); } string result = writer.ToString(); char[] sep = { '\n' }; string[] lines = result.Split(sep); for (int i = 0; i < lines.Length; i++) { string line = lines[i].Trim(); if (line.Length == 0) { continue; } form.LogInfo = line; } } finally { writer.close(); } } finally { reader.close(); } return(database != null); }
private void RunCompile(Source source) { source.Clear(); java.io.StringWriter writer = new java.io.StringWriter(); try { java.io.PrintWriter log = new java.io.PrintWriter(writer); try { string currDir = Directory.GetCurrentDirectory(); try { FileInfo info = new FileInfo(source.FileName); LogVerbose = "Changing to " + info.DirectoryName; Directory.SetCurrentDirectory(info.DirectoryName); LogVerbose = "Compiling " + info.Name; bbd.jportal.Database database = JPortal.run(info.FullName, log); RunGenerators(database, log); } finally { Directory.SetCurrentDirectory(currDir); } } finally { log.flush(); log.close(); } string result = writer.ToString(); char[] sep = { '\n' }; string[] lines = result.Split(sep); for (int i = 0; i < lines.Length; i++) { string line = lines[i].Trim(); if (line.Length == 0) { continue; } if (line.IndexOf("Code: ") == 0) { source.Add(line.Substring(6).Trim()); } else if (line.IndexOf("DDL: ") == 0) { source.Add(line.Substring(5).Trim()); } LogInfo = line; } } finally { writer.close(); } }
void sendFileUsingWriter(HttpServletResponse resp, string filename) { java.io.PrintWriter writer = resp.getWriter(); try { resp.setContentType(this.getServletContext().getMimeType(filename)); StreamReader fis = null; char[] buf = new char[4 * 1024]; // 4K buffer try { fis = new StreamReader(filename); int charsRead; while ((charsRead = fis.Read(buf, 0, buf.Length)) != -1 && charsRead != 0) { writer.write(buf, 0, charsRead); } } finally { if (fis != null) { fis.Close(); } } } catch (System.IO.FileNotFoundException e) { resp.setStatus(404, "Object Not Found."); HttpException myExp = new HttpException(404, "File '" + filename + "' not found."); writer.print(((HttpException)myExp).GetHtmlErrorMessage()); writer.flush(); } catch (Exception e) { Trace.WriteLine(String.Format("ERROR in Static File Reading {0},{1}", e.GetType(), e.Message)); resp.setStatus(500); HttpException myExp = new HttpException("Exception in Reading static file", e); writer.print(((HttpException)myExp).GetHtmlErrorMessage()); writer.flush(); } }
/// <hide></hide> public virtual void dumpGfxInfo(java.io.FileDescriptor fd) { java.io.FileOutputStream fout = new java.io.FileOutputStream(fd); java.io.PrintWriter pw = new java.io.PrintWriter(fout); try { lock (this) { if (mViews != null) { pw.println("View hierarchy:"); int count = mViews.Length; int viewsCount = 0; int displayListsSize = 0; int[] info = new int[2]; { for (int i = 0; i < count; i++) { android.view.ViewRootImpl root = mRoots[i]; root.dumpGfxInfo(pw, info); string name = root.GetType().FullName + '@' + Sharpen.Util.IntToHexString(GetHashCode ()); pw.printf(" %s: %d views, %.2f kB (display lists)\n", name, info[0], info[1] / 1024.0f ); viewsCount += info[0]; displayListsSize += info[1]; } } pw.printf("\nTotal ViewRootImpl: %d\n", count); pw.printf("Total Views: %d\n", viewsCount); pw.printf("Total DisplayList: %.2f kB\n\n", displayListsSize / 1024.0f); } } } finally { pw.flush(); } }
protected static void Log(string str) { s_logFileWriter.println(str); s_logFileWriter.flush(); }
internal void handleDumpActivity(android.app.ActivityThread.DumpComponentInfo info ) { android.app.ActivityThread.ActivityClientRecord r = mActivities.get(info.token); if (r != null && r.activity != null) { java.io.PrintWriter pw = new java.io.PrintWriter(new java.io.FileOutputStream(info .fd.getFileDescriptor())); r.activity.dump(info.prefix, info.fd.getFileDescriptor(), pw, info.args); pw.flush(); try { info.fd.close(); } catch (System.IO.IOException) { } } }
internal void handleDumpService(android.app.ActivityThread.DumpComponentInfo info ) { android.app.Service s = mServices.get(info.token); if (s != null) { java.io.PrintWriter pw = new java.io.PrintWriter(new java.io.FileOutputStream(info .fd.getFileDescriptor())); s.dump(info.fd.getFileDescriptor(), pw, info.args); pw.flush(); try { info.fd.close(); } catch (System.IO.IOException) { } } }