public void Test_FileHidden() { switch (System.Environment.OSVersion.Platform) { case PlatformID.Unix: case PlatformID.MacOSX: String name = java.lang.SystemJ.getProperty("java.io.tmpdir") + ".VampireApi.secret"; java.io.File hidden = new java.io.File(name); if (!hidden.exists()) { String content = "secret=geheimnis"; byte[] value = System.Text.Encoding.GetEncoding("utf-8").GetBytes(content); java.io.FileOutputStream fos = new java.io.FileOutputStream(name); fos.write(value, 0, value.Length); fos.flush(); fos.close(); } Assert.True(new java.io.File(name).exists(), "java.io.File.exists() found not file " + name); Assert.True(hidden.isHidden(), "File " + hidden.toString() + " should be hidden"); break; default: Assert.Warn("Test_FileHidden not implemented for this platform"); break; } }
public void Test_WriteSimpleFile() { String name = java.lang.SystemJ.getProperty("java.io.tmpdir") + "VampireApi4U.html"; String content = "<html><body><h1>Just Another Vampire Api 4 .net, aka Java4.net</h1></body></html>"; byte[] value = System.Text.Encoding.GetEncoding("utf-8").GetBytes(content); java.io.FileOutputStream fos = new java.io.FileOutputStream(name); fos.write(value, 0, value.Length); fos.flush(); fos.close(); Assert.False(new java.io.File(java.lang.SystemJ.getProperty("java.io.tmpdir") + "not.exist").exists(), "java.io.File.exists() found not existing file"); Assert.True(new java.io.File(name).exists(), "write simple file error"); Assert.AreEqual(81, new java.io.File(name).length(), "content size of file unexpected"); }
static void Main() { String[] pangramm = { "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux?", // de "The quick brown fox jumps over the lazy dog", // en "Portez ce vieux whisky au juge blond qui fume", // fr "Эй, жлоб! Где туз? Прячь юных съёмщиц в шкаф", // ru "Chwyć małżonkę, strój bądź pleśń z fugi.", // pl "V kožuščku hudobnega fanta stopiclja mizar in kliče.", // sl "以呂波耳本へ止 千利奴流乎和加 餘多連曽津祢那 良牟有為能於久 耶万計不己衣天 阿佐伎喩女美之 恵比毛勢須", // jp }; java.io.FileOutputStream fos = new java.io.FileOutputStream("c:/temp/sample.txt"); foreach (String p in pangramm) { fos.write(p.getBytes()); } fos.flush(); fos.close(); }