Пример #1
0
        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;
            }
        }
Пример #2
0
        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");
        }
Пример #3
0
 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();
 }
Пример #4
0
 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();
 }
Пример #5
0
        public void extractBZip2Test()
        {
            int buffersize = 4096;

            java.io.File bz2 = new java.io.File("C:\\Develop\\Projekte\\J.net\\JavApi Test\\org\\apache\\commons\\compress\\bzip2\\ASL2.bz2");
            java.lang.SystemJ.outJ.println(bz2.toString());
            java.io.FileInputStream     fin  = new java.io.FileInputStream(bz2);
            java.io.BufferedInputStream inJ  = new java.io.BufferedInputStream(fin);
            java.io.FileOutputStream    outJ = new java.io.FileOutputStream("C:\\Develop\\Projekte\\J.net\\JavApi Commons Compress (Apache Port)\\archive.tar");
            org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream bzIn = new org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream(inJ);
            byte[] buffer = new byte[buffersize];
            int    n      = 0;

            while (-1 != (n = bzIn.read(buffer)))
            {
                outJ.write(buffer, 0, n);
            }
            outJ.close();
            bzIn.close();
        }