private void BtnExport_Click(object sender, EventArgs e) { // throw new NotImplementedException(); try { textViewTips.Text = "正在进行配置导出,请等待"; JSONStringer js = new JSONStringer(); var dataService = Singleton.GetDataService; string Setting = dataService.AllSettings.ToJson(); string LightExamGroup = dataService.AllLightExamItems.ToJson(); string Map = dataService.GetAllMapLines().ToJson(); string config = Setting + "@" + LightExamGroup + "@" + Map; File file = new File(DictoryPath, "config.config"); BufferedWriter bw = new BufferedWriter(new FileWriter(file, false)); bw.Write(config); bw.Flush(); textViewTips.Text = "配置导出成功"; } catch (Exception ex) { textViewTips.Text = "一键导出失败"; Logger.Error("一键导出", ex.Message); } //串口服务器//自己买一个呗//好简单的东西哟 //一键导出把配置,灯光分组,以及地图都导出 }
private void BtnMapExport_Click(object sender, EventArgs e) { try { //string Map = dataService.GetAllMapLines().ToJson(); var maps = dataService.GetAllMapLines(); if (!System.IO.Directory.Exists(DictoryPath + "/" + "map")) { System.IO.Directory.CreateDirectory(DictoryPath + "/" + "map"); } else { System.IO.DirectoryInfo theFolder = new System.IO.DirectoryInfo(DictoryPath + "/" + "map"); foreach (var item in theFolder.GetFiles()) { //每次导出我会清空整个文件夹 System.IO.File.Delete(item.FullName); } } foreach (var item in maps) { File file = new File(DictoryPath + "/" + "map", item.Name + ".map"); BufferedWriter bw = new BufferedWriter(new FileWriter(file, false)); bw.Write(item.ToJson()); bw.Flush(); } textViewTips.Text = "地图导出成功"; } catch (Exception ex) { textViewTips.Text = "地图导出失败" + ex.Message; } }
/// <summary> /// Outputs the device name and ip. /// </summary> /// <param name="outputSocket">Output socket.</param> /// <param name="deviceName">Device name.</param> /// <param name="deviceAddress">Device address.</param> //端末名とIPアドレスのセットを送る void outputDeviceNameAndIp(Socket outputSocket, String deviceName, String deviceAddress)//*** Host And Guest *** { BufferedWriter bufferedWriter; try { bufferedWriter = new BufferedWriter( new OutputStreamWriter(outputSocket.OutputStream) ); //デバイス名を書き込む bufferedWriter.Write(deviceName); bufferedWriter.NewLine(); //IPアドレスを書き込む bufferedWriter.Write(deviceAddress); bufferedWriter.NewLine(); //出力終了の文字列を書き込む bufferedWriter.Write("outputFinish"); //出力する bufferedWriter.Flush(); } catch (IOException e) { e.PrintStackTrace(); } }
public static void Print(string bt_printer, string value) { try{ if (bt_printer != "" || bt_printer != null || bt_printer.Length > 0) { var x = BluetoothAdapter.DefaultAdapter.BondedDevices; BluetoothSocket socket = null; BufferedReader inReader = null; BufferedWriter outReader = null; BluetoothDevice hxm = BluetoothAdapter.DefaultAdapter.GetRemoteDevice(bt_printer); UUID applicationUUID = UUID.FromString("00001101-0000-1000-8000-00805F9B34FB"); socket = hxm.CreateRfcommSocketToServiceRecord(applicationUUID); socket.Connect(); inReader = new BufferedReader(new InputStreamReader(socket.InputStream)); outReader = new BufferedWriter(new OutputStreamWriter(socket.OutputStream)); outReader.Write(value); outReader.Flush(); Thread.Sleep(5 * 1000); var s = inReader.Ready(); inReader.Skip(0); //close all inReader.Close(); socket.Close(); outReader.Close(); } }catch (Exception ex) { Shared.Services.Logs.Insights.Send("Print", ex); } }
public void put(string key, string value) { File file = mCache.newFile(key); BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(file), 1024); writer.Write(value); } catch (IOException ex) { ex.PrintStackTrace(); } finally { if (writer != null) { try { writer.Flush(); writer.Dispose(); } catch (IOException ex) { ex.PrintStackTrace(); } } mCache.put(file); } }
public void WriteSensorLog(IEnumerable <string> commands) { try { if (IsLogEnable) { File file = new File(Android.OS.Environment.ExternalStorageDirectory, SensorFileName + ".txt"); //第二个参数意义是说是否以append方式添加内容 BufferedWriter bw = new BufferedWriter(new FileWriter(file, true)); //记录日志时间 //记录时间 string info = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "-"; //我需要记录我接收到这条数据的时间 for (int i = 0; i < commands.Count(); i++) { if (i == 0) { bw.Write(info + commands.ElementAt(i)); } else { bw.Write(commands.ElementAt(i)); } bw.Write("\r\n"); } bw.Flush(); } } catch (Exception ex) { return; } }
private void WriteTextFile(File file, string text) { using (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) { writer.Write(text); writer.Flush(); } }
public override void Run() { int failures = 0; try { FileOutputStream fos = new FileOutputStream(this.filename); OutputStreamWriter ow = new OutputStreamWriter(fos, "utf-8"); BufferedWriter bw = new BufferedWriter(ow); foreach (IList <IHasWord> sentence in this.sentences) { Tree tree = this._enclosing.parser.ParseTree(sentence); if (tree == null) { ++failures; ParserPanel.log.Info("Failed on sentence " + sentence); } else { bw.Write(tree.ToString()); bw.NewLine(); } this.progress.SetValue(this.progress.GetValue() + 1); if (this.cancelled) { break; } } bw.Flush(); bw.Close(); ow.Close(); fos.Close(); } catch (IOException e) { JOptionPane.ShowMessageDialog(this._enclosing, "Could not save file " + this.filename + "\n" + e, null, JOptionPane.ErrorMessage); Sharpen.Runtime.PrintStackTrace(e); this._enclosing.SetStatus("Error saving parsed document"); } if (failures == 0) { this.button.SetText("Success!"); } else { this.button.SetText("Done. " + failures + " parses failed"); } if (this.cancelled && failures == 0) { this.dialog.SetVisible(false); } else { this.button.AddActionListener(null); } }
private void BtnWindowsMapExport_Click(object sender, EventArgs e) { string Map = dataService.GetAllMapLines().ToJson(); string MapName = DataBase.Currentversion.VersionName + DateTime.Now.ToString("yyyyMMddHHmmss") + ".map"; Java.IO.File file = new Java.IO.File(DictoryPath, MapName); BufferedWriter bw = new BufferedWriter(new FileWriter(file, false)); bw.Write(Map); bw.Flush(); textViewTips.Text = "地图导出成功"; }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); OxyPlot.Xamarin.Forms.Platform.Android.PlotViewRenderer.Init(); LoadApplication(new App(new AndroidInitializer())); AppDomain.CurrentDomain.UnhandledException += (s, e) => { var exception = e.ExceptionObject as Exception; var filePath = RootFolderPath + $"/Exception_{DateTime.Now.ToString("yyyyMMdd-HHmmss")}.txt"; var fos = new FileStream(filePath, FileMode.CreateNew); var osw = new OutputStreamWriter(fos, "UTF-8"); var bw = new BufferedWriter(osw); bw.Write(exception.Message + "\n" + exception.StackTrace); bw.Flush(); bw.Close(); }; TaskScheduler.UnobservedTaskException += (s, e) => { var filePath = RootFolderPath + $"/Exception_{DateTime.Now.ToString("yyyyMMdd-HHmmss")}.txt"; var fos = new FileStream(filePath, FileMode.CreateNew); var osw = new OutputStreamWriter(fos, "UTF-8"); var bw = new BufferedWriter(osw); bw.Write(e.Exception.Message + "\n" + e.Exception.StackTrace); bw.Flush(); bw.Close(); }; AndroidEnvironment.UnhandledExceptionRaiser += (s, e) => { var filePath = RootFolderPath + $"/Exception_{DateTime.Now.ToString("yyyyMMdd-HHmmss")}.txt"; var fos = new FileStream(filePath, FileMode.CreateNew); var osw = new OutputStreamWriter(fos, "UTF-8"); var bw = new BufferedWriter(osw); bw.Write(e.Exception.Message + "\n" + e.Exception.StackTrace); bw.Flush(); bw.Close(); }; }
/// <summary> /// Run a very simple server. /// </summary> private void RunServer() { try { Log.I("SimpleHttpServer", "Creating server socket"); var serverSocket = new ServerSocket(PORT); var requestCount = 0; try { while (!stop) { Log.I("SimpleHttpServer", "Waiting for connection"); var socket = serverSocket.Accept(); var input = new BufferedReader(new InputStreamReader(socket.GetInputStream())); var output = new BufferedWriter(new OutputStreamWriter(socket.GetOutputStream())); string line; Log.I("SimpleHttpServer", "Reading request"); while ((line = input.ReadLine()) != null) { Log.I("SimpleHttpServer", "Received: " + line); if (line.Length == 0) { break; } } Log.I("SimpleHttpServer", "Sending response"); output.Write("HTTP/1.1 200 OK\r\n"); output.Write("\r\n"); output.Write(string.Format("Hello world {0}\r\n", requestCount)); output.Flush(); socket.Close(); requestCount++; } } finally { serverSocket.Close(); } } catch (Exception ex) { Log.E("SimpleHttpServer", "Connection error", ex); } }
private void BtnSettingExport_Click(object sender, EventArgs e) { try { string Setting = dataService.AllSettings.ToJson(); File file = new File(DictoryPath, "Setting.config"); BufferedWriter bw = new BufferedWriter(new FileWriter(file, false)); bw.Write(Setting); bw.Flush(); textViewTips.Text = "参数配置导出成功"; } catch (Exception ex) { textViewTips.Text = "参数配置导出失败" + ex.Message; } }
private void BtnLightExport_Click(object sender, EventArgs e) { try { string LightExamGroup = dataService.AllLightExamItems.ToJson(); File file = new File(DictoryPath, "Light.config"); BufferedWriter bw = new BufferedWriter(new FileWriter(file, false)); bw.Write(LightExamGroup); bw.Flush(); textViewTips.Text = "灯光配置导出成功"; } catch (Exception ex) { textViewTips.Text = "灯光配置导出失败" + ex.Message; } }
public void Log(string logMessage) { if (logFile == null) { logFile = GetLogFile(); } FileWriter fileWriter = new FileWriter(logFile, true); BufferedWriter bufferedWriter = new BufferedWriter(fileWriter); DateTime currentTime = new DateTime(DateTime.Now.Ticks); string currentlogtime = DateTime.Now.ToString() + " " + GetVersion(); bufferedWriter.Append(currentlogtime + ": " + logMessage); bufferedWriter.NewLine(); bufferedWriter.Flush(); bufferedWriter.Close(); }
public static void WriteAuthFile(string Msg, string FileName) { try { File file = new File(Android.OS.Environment.ExternalStorageDirectory, FileName); //第二个参数意义是说是否以append方式添加内容 BufferedWriter bw = new BufferedWriter(new FileWriter(file, false)); //记录日志时间 //自动换行 bw.Write(Msg); bw.Flush(); } catch (Exception ex) { } }
/// <summary> /// Run a very simple server. /// </summary> private void RunServer() { try { Log.I("SimpleHttpServer", "Creating server socket"); var serverSocket = new ServerSocket(PORT); var requestCount = 0; try { while (!stop) { Log.I("SimpleHttpServer", "Waiting for connection"); var socket = serverSocket.Accept(); var input = new BufferedReader(new InputStreamReader(socket.GetInputStream())); var output = new BufferedWriter(new OutputStreamWriter(socket.GetOutputStream())); string line; Log.I("SimpleHttpServer", "Reading request"); while ((line = input.ReadLine()) != null) { Log.I("SimpleHttpServer", "Received: " + line); if (line.Length == 0) break; } Log.I("SimpleHttpServer", "Sending response"); output.Write("HTTP/1.1 200 OK\r\n"); output.Write("\r\n"); output.Write(string.Format("Hello world {0}\r\n", requestCount)); output.Flush(); socket.Close(); requestCount++; } } finally { serverSocket.Close(); } } catch (Exception ex) { Log.E("SimpleHttpServer", "Connection error", ex); } }
public void UncaughtException(Thread thread, Throwable ex) { File file = new File(Android.OS.Environment.ExternalStorageDirectory, "SpecialError.txt"); //第二个参数意义是说是否以append方式添加内容 BufferedWriter bw = new BufferedWriter(new FileWriter(file, true)); //记录日志时间 string info = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff") + "---" + ex.Message; //自动换行 bw.Write(info); bw.Write("\r\n");// bw.Flush(); // showToast(mContext, "很抱歉,程序遭遇异常,即将退出!"); Toast.MakeText(mContext, "很抱歉,程序遭遇异常,即将退出!", ToastLength.Long); Thread.Sleep(2000); }
public string Print(string deviceName, string printText) { try { BluetoothSocket socket = null; BufferedReader inReader = null; BufferedWriter outReader = null; BluetoothAdapter adapter = BluetoothAdapter.DefaultAdapter; if (adapter.BondedDevices.Count == 0) // update by Zhi Hong Lim { throw new System.Exception("Bluetooth is not turned on."); } string bt_printer = (from d in adapter.BondedDevices where d.Name == deviceName select d.Address).FirstOrDefault().ToString(); BluetoothDevice device = adapter.GetRemoteDevice(bt_printer); UUID applicationUUID = UUID.FromString("00001101-0000-1000-8000-00805F9B34FB"); socket = device.CreateRfcommSocketToServiceRecord(applicationUUID); socket.Connect(); inReader = new BufferedReader(new InputStreamReader(socket.InputStream)); outReader = new BufferedWriter(new OutputStreamWriter(socket.OutputStream)); outReader.Write(printText); outReader.Flush(); Thread.Sleep(1000); var s = inReader.Ready(); inReader.Skip(0); //Close All inReader.Close(); outReader.Close(); socket.Close(); return("Success"); } catch (Java.Lang.Exception ex) { return(ex.Message.ToString()); } }
public virtual void SetUp() { lock (typeof(RegexNERSequenceClassifierTest)) { if (tempFile == null) { tempFile = File.CreateTempFile("regexnertest.patterns", "txt"); FileWriter fout = new FileWriter(tempFile); BufferedWriter bout = new BufferedWriter(fout); bout.Write("sausage\tfood\n"); bout.Write("(avocet|curlew)(s?)\tshorebird\n"); bout.Write("shoreline park\tpark\n"); bout.Flush(); fout.Close(); } } sentences = new List <IList <CoreLabel> >(); NERsentences = new List <IList <CoreLabel> >(); NUnit.Framework.Assert.AreEqual(words.Length, tags.Length); NUnit.Framework.Assert.AreEqual(words.Length, ner.Length); for (int snum = 0; snum < words.Length; ++snum) { string[] wordPieces = words[snum].Split(" "); string[] tagPieces = tags[snum].Split(" "); string[] nerPieces = ner[snum].Split(" "); NUnit.Framework.Assert.AreEqual(wordPieces.Length, tagPieces.Length); NUnit.Framework.Assert.AreEqual(wordPieces.Length, nerPieces.Length, "Input " + snum + " " + words[snum] + " of different length than " + ner[snum]); IList <CoreLabel> sentence = new List <CoreLabel>(); IList <CoreLabel> NERsentence = new List <CoreLabel>(); for (int wnum = 0; wnum < wordPieces.Length; ++wnum) { CoreLabel token = new CoreLabel(); token.SetWord(wordPieces[wnum]); token.SetTag(tagPieces[wnum]); sentence.Add(token); CoreLabel NERtoken = new CoreLabel(); NERtoken.SetWord(wordPieces[wnum]); NERtoken.SetTag(tagPieces[wnum]); NERtoken.SetNER(nerPieces[wnum]); NERsentence.Add(NERtoken); } sentences.Add(sentence); NERsentences.Add(NERsentence); } }
/// <summary> Runs the test. /// </summary> public virtual void runTest() { try { assureResultsDirectoryExists(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR); /* * Get the template and the output. Do them backwards. * vm_test2 uses a local VM and vm_test1 doesn't */ Template template2 = RuntimeSingleton.getTemplate(getFileName(null, "vm_test2", org.apache.velocity.test.TemplateTestBase_Fields.TMPL_FILE_EXT)); Template template1 = RuntimeSingleton.getTemplate(getFileName(null, "vm_test1", org.apache.velocity.test.TemplateTestBase_Fields.TMPL_FILE_EXT)); System.IO.FileStream fos1 = new System.IO.FileStream(getFileName(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, "vm_test1", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT), System.IO.FileMode.Create); System.IO.FileStream fos2 = new System.IO.FileStream(getFileName(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, "vm_test2", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT), System.IO.FileMode.Create); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' System.IO.StreamWriter writer1 = new BufferedWriter(new System.IO.StreamWriter(fos1)); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' System.IO.StreamWriter writer2 = new BufferedWriter(new System.IO.StreamWriter(fos2)); /* * put the Vector into the context, and merge both */ VelocityContext context = new VelocityContext(); template1.merge(context, writer1); writer1.Flush(); writer1.Close(); template2.merge(context, writer2); writer2.Flush(); writer2.Close(); if (!isMatch(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, org.apache.velocity.test.TemplateTestBase_Fields.COMPARE_DIR, "vm_test1", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT, org.apache.velocity.test.TemplateTestBase_Fields.CMP_FILE_EXT) || !isMatch(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, org.apache.velocity.test.TemplateTestBase_Fields.COMPARE_DIR, "vm_test2", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT, org.apache.velocity.test.TemplateTestBase_Fields.CMP_FILE_EXT)) { fail("Output incorrect."); } } catch (System.Exception e) { fail(e.Message); } }
/// <exception cref="System.Exception"/> public static void Print(string[][] cols) { BufferedWriter @out = new BufferedWriter(new FileWriter(outputFilename)); foreach (string[] col in cols) { if (col.Length >= 2) { @out.Write(col[0] + "\t" + col[1] + "\n"); } else { @out.Write("\n"); } } @out.Flush(); @out.Close(); }
private static void WriteTrees(string filename, IList <Tree> trees, IList <int> treeIds) { try { FileOutputStream fos = new FileOutputStream(filename); BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(fos)); foreach (int id in treeIds) { bout.Write(trees[id].ToString()); bout.Write("\n"); } bout.Flush(); fos.Close(); } catch (IOException e) { throw new RuntimeIOException(e); } }
/// <summary> Runs the test. /// </summary> public virtual void runTest() { try { /* * lets ensure the results directory exists */ assureResultsDirectoryExists(RESULTS_DIR); Template template1 = RuntimeSingleton.getTemplate(getFileName(null, "template/test1", TMPL_FILE_EXT)); Template template2 = RuntimeSingleton.getTemplate(getFileName(null, "template/test2", TMPL_FILE_EXT)); System.IO.FileStream fos1 = new System.IO.FileStream(getFileName(RESULTS_DIR, "test1", RESULT_FILE_EXT), System.IO.FileMode.Create); System.IO.FileStream fos2 = new System.IO.FileStream(getFileName(RESULTS_DIR, "test2", RESULT_FILE_EXT), System.IO.FileMode.Create); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' System.IO.StreamWriter writer1 = new BufferedWriter(new System.IO.StreamWriter(fos1)); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' System.IO.StreamWriter writer2 = new BufferedWriter(new System.IO.StreamWriter(fos2)); /* * put the Vector into the context, and merge both */ VelocityContext context = new VelocityContext(); template1.merge(context, writer1); writer1.Flush(); writer1.Close(); template2.merge(context, writer2); writer2.Flush(); writer2.Close(); if (!isMatch(RESULTS_DIR, COMPARE_DIR, "test1", RESULT_FILE_EXT, CMP_FILE_EXT) || !isMatch(RESULTS_DIR, COMPARE_DIR, "test2", RESULT_FILE_EXT, CMP_FILE_EXT)) { fail("Output is incorrect!"); } } catch (System.Exception e) { fail(e.Message); } }
/// <summary>write cofiguration</summary> /// <returns/> /// <exception cref="System.IO.IOException"/> private FilePath WriteFile() { FilePath f = new FilePath(testDir, "tst.xml"); BufferedWriter @out = new BufferedWriter(new FileWriter(f)); string properties = "<properties><property key=\"key\" value=\"value\"/><property key=\"key1\" value=\"value1\"/></properties>"; @out.Write("<queues>"); @out.NewLine(); @out.Write("<queue><name>first</name><acl-submit-job>user1,user2 group1,group2</acl-submit-job><acl-administer-jobs>user3,user4 group3,group4</acl-administer-jobs><state>running</state></queue>" ); @out.NewLine(); @out.Write("<queue><name>second</name><acl-submit-job>u1,u2 g1,g2</acl-submit-job>" + properties + "<state>stopped</state></queue>"); @out.NewLine(); @out.Write("</queues>"); @out.Flush(); @out.Close(); return(f); }
public void WriteFile(string Msg, string FileName) { try { File file = new File(Android.OS.Environment.ExternalStorageDirectory + "/" + this.FolderName, FileName + ".txt"); //第二个参数意义是说是否以append方式添加内容 BufferedWriter bw = new BufferedWriter(new FileWriter(file, true)); //记录日志时间 string info = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff") + "---" + Msg; //自动换行 bw.Write(info); bw.Write("\r\n");// bw.Flush(); } catch (Exception ex) { Error("WriteLog" + ex.Message); } }
public static void WriteSystemLog(string Msg) { try { File file = new File(Android.OS.Environment.ExternalStorageDirectory, "SystemLog" + ".txt"); //第二个参数意义是说是否以append方式添加内容 BufferedWriter bw = new BufferedWriter(new FileWriter(file, true)); //记录日志时间 string info = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff") + "---" + Msg; //自动换行 bw.Write(info); bw.Write("\r\n");// bw.Flush(); } catch (Exception ex) { return; } }
public void Write(string data) { if (socket == null || !socket.IsConnected) { return; } using (var stream = socket.OutputStream) using (var writer = new BufferedWriter(new OutputStreamWriter(stream))) { try { writer.Write(data); writer.Flush(); Debug.Write("DATA HAS BEEN WRITTEN"); } catch (System.Exception ex) { Debug.WriteLine("EXCEPTION: " + ex.Message); } } }
/// <summary>Tcp /// Gets the ip address. /// </summary> /// <returns>The ip address.</returns> //public string getIpAddress() //{ // string IpAddress = "1234"; // return IpAddress; //} /// <summary>Tcp /// Outputs the device name and ip. /// 端末名とIPアドレスのセットをゲストに送る /// </summary> /// <param name="outputSocket">Output socket.</param> /// <param name="deviceName">Device name.</param> /// <param name="deviceAddress">Device address.</param> void outputDeviceNameAndIp(Socket outputSocket, String deviceName, String deviceAddress) { BufferedWriter bufferedWriter; try { bufferedWriter = new BufferedWriter( new OutputStreamWriter(outputSocket.OutputStream) ); //(3)FileOutputStreamオブジェクトの生成 // OutputStream xyz = new OutputStream("xyz.txt"); //(5)OutputStreamWriterオブジェクトの生成 //bufferedWriter = new BufferedWriter( // new OutputStreamWriter(xyz, "Shift_JIS") //); //デバイス名を書き込む bufferedWriter.Write(deviceName); bufferedWriter.NewLine(); //IPアドレスを書き込む bufferedWriter.Write(deviceAddress); bufferedWriter.NewLine(); //出力終了の文字列を書き込む bufferedWriter.Write("outputFinish"); //出力する bufferedWriter.Flush(); } catch (IOException e) { e.PrintStackTrace(); } }
public void Flush() { _writer.Flush(); }
/// <exception cref="System.IO.IOException"/> public static void Main(string[] args) { string modelPath = null; string outputPath = null; string inputPath = null; string testTreebankPath = null; IFileFilter testTreebankFilter = null; IList <string> unusedArgs = Generics.NewArrayList(); for (int argIndex = 0; argIndex < args.Length;) { if (Sharpen.Runtime.EqualsIgnoreCase(args[argIndex], "-model")) { modelPath = args[argIndex + 1]; argIndex += 2; } else { if (Sharpen.Runtime.EqualsIgnoreCase(args[argIndex], "-output")) { outputPath = args[argIndex + 1]; argIndex += 2; } else { if (Sharpen.Runtime.EqualsIgnoreCase(args[argIndex], "-input")) { inputPath = args[argIndex + 1]; argIndex += 2; } else { if (Sharpen.Runtime.EqualsIgnoreCase(args[argIndex], "-testTreebank")) { Pair <string, IFileFilter> treebankDescription = ArgUtils.GetTreebankDescription(args, argIndex, "-testTreebank"); argIndex = argIndex + ArgUtils.NumSubArgs(args, argIndex) + 1; testTreebankPath = treebankDescription.First(); testTreebankFilter = treebankDescription.Second(); } else { unusedArgs.Add(args[argIndex++]); } } } } } string[] newArgs = Sharpen.Collections.ToArray(unusedArgs, new string[unusedArgs.Count]); LexicalizedParser parser = ((LexicalizedParser)LexicalizedParser.LoadModel(modelPath, newArgs)); DVModel model = DVParser.GetModelFromLexicalizedParser(parser); File outputFile = new File(outputPath); FileSystem.CheckNotExistsOrFail(outputFile); FileSystem.MkdirOrFail(outputFile); int count = 0; if (inputPath != null) { Reader input = new BufferedReader(new FileReader(inputPath)); DocumentPreprocessor processor = new DocumentPreprocessor(input); foreach (IList <IHasWord> sentence in processor) { count++; // index from 1 IParserQuery pq = parser.ParserQuery(); if (!(pq is RerankingParserQuery)) { throw new ArgumentException("Expected a RerankingParserQuery"); } RerankingParserQuery rpq = (RerankingParserQuery)pq; if (!rpq.Parse(sentence)) { throw new Exception("Unparsable sentence: " + sentence); } IRerankerQuery reranker = rpq.RerankerQuery(); if (!(reranker is DVModelReranker.Query)) { throw new ArgumentException("Expected a DVModelReranker"); } DeepTree deepTree = ((DVModelReranker.Query)reranker).GetDeepTrees()[0]; IdentityHashMap <Tree, SimpleMatrix> vectors = deepTree.GetVectors(); foreach (KeyValuePair <Tree, SimpleMatrix> entry in vectors) { log.Info(entry.Key + " " + entry.Value); } FileWriter fout = new FileWriter(outputPath + File.separator + "sentence" + count + ".txt"); BufferedWriter bout = new BufferedWriter(fout); bout.Write(SentenceUtils.ListToString(sentence)); bout.NewLine(); bout.Write(deepTree.GetTree().ToString()); bout.NewLine(); foreach (IHasWord word in sentence) { OutputMatrix(bout, model.GetWordVector(word.Word())); } Tree rootTree = FindRootTree(vectors); OutputTreeMatrices(bout, rootTree, vectors); bout.Flush(); fout.Close(); } } }
public Test(System.String templateFile, System.String encoding) { System.IO.StreamWriter writer = null; TestProvider provider = new TestProvider(); ArrayList al = provider.Customers; System.Collections.Hashtable h = new System.Collections.Hashtable(); /* * put this in to test introspection $h.Bar or $h.get("Bar") etc */ SupportClass.PutElement(h, "Bar", "this is from a hashtable!"); SupportClass.PutElement(h, "Foo", "this is from a hashtable too!"); /* * adding simple vector with strings for testing late introspection stuff */ System.Collections.ArrayList v = new System.Collections.ArrayList(); System.String str = "mystr"; v.Add(new System.String("hello".ToCharArray())); v.Add(new System.String("hello2".ToCharArray())); v.Add(str); try { /* * this is another way to do properties when initializing Runtime. * make a Properties */ //UPGRADE_TODO: Format of property file may need to be changed. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1089"' System.Configuration.AppSettingsReader p = new System.Configuration.AppSettingsReader(); /* * now, if you want to, load it from a file (or whatever) */ try { System.IO.FileStream fis = new System.IO.FileStream(new System.IO.FileInfo("velocity.properties").FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read); if (fis != null) { //UPGRADE_ISSUE: Method 'java.util.Properties.load' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javautilPropertiesload_javaioInputStream"' p.load(fis); } } catch (System.Exception ex) { /* no worries. no file... */ } /* * iterate out the properties */ System.Collections.Specialized.NameValueCollection temp_namedvaluecollection; temp_namedvaluecollection = System.Configuration.ConfigurationSettings.AppSettings; //UPGRADE_TODO: method 'java.util.Enumeration.hasMoreElements' was converted to ' ' which has a different behavior. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1073_javautilEnumerationhasMoreElements"' for (System.Collections.IEnumerator e = temp_namedvaluecollection.GetEnumerator(); e.MoveNext(); ) { //UPGRADE_TODO: method 'java.util.Enumeration.nextElement' was converted to ' ' which has a different behavior. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1073_javautilEnumerationnextElement"' System.String el = (System.String) e.Current; //UPGRADE_WARNING: method 'java.util.Properties.getProperty' was converted to ' ' which may throw an exception. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1101"' Velocity.setProperty(el, (System.String) p.GetValue(el, System.Type.GetType("System.String"))); } /* * add some individual properties if you wish */ Velocity.setProperty(Velocity.RUNTIME_LOG_ERROR_STACKTRACE, "true"); Velocity.setProperty(Velocity.RUNTIME_LOG_WARN_STACKTRACE, "true"); Velocity.setProperty(Velocity.RUNTIME_LOG_INFO_STACKTRACE, "true"); /* * use an alternative logger. Set it up here and pass it in. */ // SimpleLogSystem sls = new SimpleLogSystem("velocity_simple.log"); // Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, sls ); /* * and now call init */ Velocity.init(); /* * now, do what we want to do. First, get the Template */ if (templateFile == null) { templateFile = "examples/example.vm"; } Template template = null; try { template = RuntimeSingleton.getTemplate(templateFile, encoding) ; } catch (ResourceNotFoundException rnfe) { System.Console.Out.WriteLine("Test : RNFE : Cannot find template " + templateFile); } catch (ParseErrorException pee) { System.Console.Out.WriteLine("Test : Syntax error in template " + templateFile + ":" + pee); } /* * now, make a Context object and populate it. */ VelocityContext context = new VelocityContext(); context.put("provider", provider); context.put("name", "jason"); context.put("providers", provider.Customers2); context.put("list", al); context.put("hashtable", h); context.put("search", provider.Search); context.put("relatedSearches", provider.RelSearches); context.put("searchResults", provider.RelSearches); context.put("menu", provider.Menu); context.put("stringarray", provider.Array); context.put("vector", v); context.put("mystring", new System.String("".ToCharArray())); context.put("hashmap", new HashMap()); context.put("runtime", new FieldMethodizer("org.apache.velocity.runtime.RuntimeSingleton")); context.put("fmprov", new FieldMethodizer(provider)); context.put("Floog", "floogie woogie"); context.put("geirstring", str); context.put("mylong", 5); /* * we want to make sure we test all types of iterative objects * in #foreach() */ int[] intarr = new int[]{10, 20, 30, 40, 50}; System.Object[] oarr = new System.Object[]{"a", "b", "c", "d"}; context.put("collection", v); context.put("iterator", v.iterator()); context.put("map", h); context.put("obarr", oarr); context.put("intarr", intarr); System.String stest = " My name is $name -> $Floog"; System.IO.StringWriter w = new System.IO.StringWriter(); // Velocity.evaluate( context, w, "evaltest",stest ); // System.out.println("Eval = " + w ); w = new System.IO.StringWriter(); //Velocity.mergeTemplate( "mergethis.vm", context, w ); //System.out.println("Merge = " + w ); w = new System.IO.StringWriter(); //Velocity.invokeVelocimacro( "floog", "test", new String[2], context, w ); //System.out.println("Invoke = " + w ); /* * event cartridge stuff */ EventCartridge ec = new EventCartridge(); ec.addEventHandler(this); ec.attachToContext(context); /* * make a writer, and merge the template 'against' the context */ VelocityContext vc = new VelocityContext(context); if (template != null) { //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' writer = new BufferedWriter(new System.IO.StreamWriter(System.Console.Out)); template.merge(vc, writer); writer.Flush(); writer.Close(); } } catch (MethodInvocationException mie) { System.Console.Out.WriteLine("MIE : " + mie); } catch (System.Exception e) { RuntimeSingleton.error("Test- exception : " + e); SupportClass.WriteStackTrace(e, Console.Error); } }
protected override string RunInBackground(params Dictionary <string, string>[] @params) { var _result = new StringBuilder(); var _url_connection = (HttpURLConnection)null; //Log.Debug(this.GetType().Name, $"Url:{target_url}"); try { var _url = new URL(this.target_url); { _url_connection = (HttpURLConnection)_url.OpenConnection(); _url_connection.SetRequestProperty("Authorization", ("Bearer " + this.token_key)); _url_connection.DoInput = true; _url_connection.DoOutput = true; _url_connection.RequestMethod = "POST"; _url_connection.ConnectTimeout = 5000; } if (@params.Length > 0 && @params[0] != null) { // 웹 서버로 보낼 매개변수가 있는 경우 using (var _os = _url_connection.OutputStream) // 서버로 보내기 위한 출력 스트림 { using (var _bw = new BufferedWriter(new OutputStreamWriter(_os, "UTF-8"))) // UTF-8로 전송 { _bw.Write(GetPostString(@params[0])); // 매개변수 전송 _bw.Flush(); _bw.Close(); } _os.Close(); } } if (_url_connection.ResponseCode == HttpStatus.Ok) { var _buffer = new BufferedReader(new InputStreamReader(_url_connection.InputStream)); while (true) { string _line = _buffer.ReadLine(); if (_line == null) { break; } _result.Append(_line).Append("\n"); } } else if (_url_connection.ResponseCode == HttpStatus.Unauthorized) { //Log.Debug(this.GetType().Name, "Unauthorized"); } } catch (Java.Lang.Exception ex) { Log.Error(this.GetType().Name, ex.Message); using (var h = new Handler(Looper.MainLooper)) { h.Post(() => { AppDialog.SNG.Alert(this.pcontext, "네트워크를 활성화 해주세요."); }); } } finally { if (_url_connection != null) { _url_connection.Disconnect(); } } return(_result.ToString()); }
/// <summary> Runs the test. /// </summary> public virtual void runTest() { VelocityContext context = new VelocityContext(); try { assureResultsDirectoryExists(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR); /* * get the template and the output */ /* * Chinese and spanish */ Template template = Velocity.getTemplate(getFileName(null, "encodingtest", org.apache.velocity.test.TemplateTestBase_Fields.TMPL_FILE_EXT), "UTF-8") ; System.IO.FileStream fos = new System.IO.FileStream(getFileName(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, "encodingtest", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT), System.IO.FileMode.Create); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' System.IO.StreamWriter writer = new BufferedWriter(new System.IO.StreamWriter(fos)); template.merge(context, writer); writer.Flush(); writer.Close(); if (!isMatch(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, org.apache.velocity.test.TemplateTestBase_Fields.COMPARE_DIR, "encodingtest", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT, org.apache.velocity.test.TemplateTestBase_Fields.CMP_FILE_EXT)) { fail("Output 1 incorrect."); } /* * a 'high-byte' chinese example from Michael Zhou */ template = Velocity.getTemplate(getFileName(null, "encodingtest2", org.apache.velocity.test.TemplateTestBase_Fields.TMPL_FILE_EXT), "UTF-8") ; fos = new System.IO.FileStream(getFileName(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, "encodingtest2", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT), System.IO.FileMode.Create); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' writer = new BufferedWriter(new System.IO.StreamWriter(fos)); template.merge(context, writer); writer.Flush(); writer.Close(); if (!isMatch(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, org.apache.velocity.test.TemplateTestBase_Fields.COMPARE_DIR, "encodingtest2", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT, org.apache.velocity.test.TemplateTestBase_Fields.CMP_FILE_EXT)) { fail("Output 2 incorrect."); } /* * a 'high-byte' chinese from Ilkka */ template = Velocity.getTemplate(getFileName(null, "encodingtest3", org.apache.velocity.test.TemplateTestBase_Fields.TMPL_FILE_EXT), "GBK") ; fos = new System.IO.FileStream(getFileName(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, "encodingtest3", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT), System.IO.FileMode.Create); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' writer = new BufferedWriter(new System.IO.StreamWriter(fos)); template.merge(context, writer); writer.Flush(); writer.Close(); if (!isMatch(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, org.apache.velocity.test.TemplateTestBase_Fields.COMPARE_DIR, "encodingtest3", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT, org.apache.velocity.test.TemplateTestBase_Fields.CMP_FILE_EXT)) { fail("Output 3 incorrect."); } /* * Russian example from Vitaly Repetenko */ template = Velocity.getTemplate(getFileName(null, "encodingtest_KOI8-R", org.apache.velocity.test.TemplateTestBase_Fields.TMPL_FILE_EXT), "KOI8-R") ; fos = new System.IO.FileStream(getFileName(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, "encodingtest_KOI8-R", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT), System.IO.FileMode.Create); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' writer = new BufferedWriter(new System.IO.StreamWriter(fos)); template.merge(context, writer); writer.Flush(); writer.Close(); if (!isMatch(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, org.apache.velocity.test.TemplateTestBase_Fields.COMPARE_DIR, "encodingtest_KOI8-R", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT, org.apache.velocity.test.TemplateTestBase_Fields.CMP_FILE_EXT)) { fail("Output 4 incorrect."); } } catch (System.Exception e) { fail(e.Message); } }
/// <summary> Runs the test. /// </summary> public virtual void runTest() { try { /* * lets ensure the results directory exists */ assureResultsDirectoryExists(RESULTS_DIR); /* * Template to find with the file loader. */ Template template1 = Velocity.getTemplate(getFileName(null, "path1", TMPL_FILE_EXT)); /* * Template to find with the classpath loader. */ Template template2 = Velocity.getTemplate(getFileName(null, "template/test1", TMPL_FILE_EXT)); /* * Template to find with the jar loader */ Template template3 = Velocity.getTemplate(getFileName(null, "template/test2", TMPL_FILE_EXT)); /* * and the results files */ System.IO.FileStream fos1 = new System.IO.FileStream(getFileName(RESULTS_DIR, "path1", RESULT_FILE_EXT), System.IO.FileMode.Create); System.IO.FileStream fos2 = new System.IO.FileStream(getFileName(RESULTS_DIR, "test2", RESULT_FILE_EXT), System.IO.FileMode.Create); System.IO.FileStream fos3 = new System.IO.FileStream(getFileName(RESULTS_DIR, "test3", RESULT_FILE_EXT), System.IO.FileMode.Create); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' System.IO.StreamWriter writer1 = new BufferedWriter(new System.IO.StreamWriter(fos1)); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' System.IO.StreamWriter writer2 = new BufferedWriter(new System.IO.StreamWriter(fos2)); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' System.IO.StreamWriter writer3 = new BufferedWriter(new System.IO.StreamWriter(fos3)); /* * put the Vector into the context, and merge both */ VelocityContext context = new VelocityContext(); template1.merge(context, writer1); writer1.Flush(); writer1.Close(); template2.merge(context, writer2); writer2.Flush(); writer2.Close(); template3.merge(context, writer3); writer3.Flush(); writer3.Close(); if (!isMatch(RESULTS_DIR, COMPARE_DIR, "path1", RESULT_FILE_EXT, CMP_FILE_EXT)) { fail("Output incorrect for FileResourceLoader test."); } if (!isMatch(RESULTS_DIR, COMPARE_DIR, "test2", RESULT_FILE_EXT, CMP_FILE_EXT)) { fail("Output incorrect for ClasspathResourceLoader test."); } if (!isMatch(RESULTS_DIR, COMPARE_DIR, "test3", RESULT_FILE_EXT, CMP_FILE_EXT)) { fail("Output incorrect for JarResourceLoader test."); } } catch (System.Exception e) { fail(e.Message); } }
public static string Format(string xml) { var ret = new StringWriter(); using (var escaper = new HtmlEscapingTextWriter(ret)) using (var source = new StringReader(xml)) using (var reader = XmlReader.Create(source)) using (var writer = new BufferedWriter()) { while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: ret.Write(@"<span class=""keyword""><</span>"); writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI); writer.WriteAttributes(reader, true); if (reader.IsEmptyElement) { writer.WriteEndElement(); } writer.Flush(); break; case XmlNodeType.Text: writer.WriteString(reader.Value); writer.Flush(); break; case XmlNodeType.Whitespace: case XmlNodeType.SignificantWhitespace: writer.WriteWhitespace(reader.Value); writer.Flush(); break; case XmlNodeType.CDATA: writer.WriteCData(reader.Value); writer.Flush(); break; case XmlNodeType.EntityReference: writer.WriteEntityRef(reader.Name); writer.Flush(); break; case XmlNodeType.XmlDeclaration: case XmlNodeType.ProcessingInstruction: writer.WriteProcessingInstruction(reader.Name, reader.Value); writer.Flush(); break; case XmlNodeType.DocumentType: writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value); writer.Flush(); break; case XmlNodeType.Comment: writer.WriteComment(reader.Value); writer.Flush(); break; case XmlNodeType.EndElement: writer.WriteFullEndElement(); writer.Flush(); break; } } } }
/// <summary> Runs the test. /// </summary> public virtual void runTest() { /* * make a Vector and String array because * they are treated differently in Foreach() */ System.Collections.ArrayList v = new System.Collections.ArrayList(); v.Add(new System.String("vector hello 1".ToCharArray())); v.Add(new System.String("vector hello 2".ToCharArray())); v.Add(new System.String("vector hello 3".ToCharArray())); System.String[] strArray = new System.String[3]; strArray[0] = "array hello 1"; strArray[1] = "array hello 2"; strArray[2] = "array hello 3"; VelocityContext context = new VelocityContext(); try { assureResultsDirectoryExists(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR); /* * get the template and the output */ Template template = RuntimeSingleton.getTemplate(getFileName(null, "context_safety", org.apache.velocity.test.TemplateTestBase_Fields.TMPL_FILE_EXT)) ; System.IO.FileStream fos1 = new System.IO.FileStream(getFileName(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, "context_safety1", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT), System.IO.FileMode.Create); System.IO.FileStream fos2 = new System.IO.FileStream(getFileName(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, "context_safety2", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT), System.IO.FileMode.Create); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' System.IO.StreamWriter writer1 = new BufferedWriter(new System.IO.StreamWriter(fos1)); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' System.IO.StreamWriter writer2 = new BufferedWriter(new System.IO.StreamWriter(fos2)); /* * put the Vector into the context, and merge */ context.put("vector", v); template.merge(context, writer1); writer1.Flush(); writer1.Close(); /* * now put the string array into the context, and merge */ context.put("vector", strArray); template.merge(context, writer2); writer2.Flush(); writer2.Close(); if (!isMatch(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, org.apache.velocity.test.TemplateTestBase_Fields.COMPARE_DIR, "context_safety1", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT, org.apache.velocity.test.TemplateTestBase_Fields.CMP_FILE_EXT) || !isMatch(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, org.apache.velocity.test.TemplateTestBase_Fields.COMPARE_DIR, "context_safety2", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT, org.apache.velocity.test.TemplateTestBase_Fields.CMP_FILE_EXT)) { fail("Output incorrect."); } } catch (System.Exception e) { fail(e.Message); } }