close() public method

public close ( ) : void
return void
		private void saveBytecode(String className, byte[] bytecode) {
			var generatedPath = PathHelper.combine(System.getProperty("user.dir"), "Tests/resources/TypeBuilderTest/stab");
			var generatedDir = new File(generatedPath);
			if (!generatedDir.exists()) {
				generatedDir.mkdir();
			}
			var stream = new FileOutputStream(PathHelper.combine(generatedPath, className + ".class"));
			stream.write(bytecode);
			stream.close();
		}
Example #2
0
        private void ExtractFile(ZipFile zipFile, ZipEntry zipEntry, string tempFileName)
        {
            InputStream s = zipFile.getInputStream(zipEntry);
            try
            {
                FileOutputStream dest = new FileOutputStream(tempFileName);
                try
                {
                    int len = 0;
                    sbyte[] buffer = new sbyte[7168];
                    while ((len = s.read(buffer)) >= 0)
                    {
                        dest.write(buffer, 0, len);
                    }
                }
                finally
                {
                    dest.close();
                }
            }
            finally
            {
                s.close();
            }

        }
Example #3
0
 public static void Unzip(string zipFile, string[] targetFiles, string output)
 {
     java.util.zip.ZipFile file = new java.util.zip.ZipFile(zipFile);
     try
     {
         using (List<ZipEntry>.Enumerator enumerator = GetZippedItems(file).GetEnumerator())
         {
             Predicate<string> match = null;
             ZipEntry entry;
             while (enumerator.MoveNext())
             {
                 entry = enumerator.Current;
                 if ((targetFiles != null) && (targetFiles.Length > 0))
                 {
                     if (match == null)
                     {
                         match = delegate (string s) {
                             return entry.getName().ToLower().EndsWith(s.ToLower().Replace(@"\", "/").TrimStart("/".ToCharArray()));
                         };
                     }
                     if (Array.FindIndex<string>(targetFiles, match) < 0)
                     {
                         continue;
                     }
                 }
                 if (!entry.isDirectory())
                 {
                     InputStream source = file.getInputStream(entry);
                     try
                     {
                         string fileName;
                         string directoryName;
                         if (Path.HasExtension(output) && !Directory.Exists(output))
                         {
                             fileName = Path.GetFileName(output);
                             directoryName = Path.GetDirectoryName(output);
                         }
                         else
                         {
                             fileName = Path.GetFileName(entry.getName());
                             directoryName = Path.GetDirectoryName(entry.getName());
                             directoryName = output + @"\" + directoryName;
                         }
                         Directory.CreateDirectory(directoryName);
                         FileOutputStream destination = new FileOutputStream(Path.Combine(directoryName, fileName));
                         try
                         {
                             CopyStream(source, destination);
                         }
                         finally
                         {
                             destination.close();
                         }
                         continue;
                     }
                     finally
                     {
                         source.close();
                     }
                 }
             }
         }
     }
     finally
     {
         if (file != null)
         {
             file.close();
         }
     }
 }
 public static void savePreferences()
 {
   FileOutputStream.__\u003Cclinit\u003E();
   FileOutputStream fileOutputStream = new FileOutputStream(BaseTestRunner.getPreferencesFile());
   try
   {
     BaseTestRunner.getPreferences().store((OutputStream) fileOutputStream, "");
   }
   finally
   {
     fileOutputStream.close();
   }
 }
        //使用nlp將文章分析後回傳key
        private List<string> nlp(string sentence)
        {
            List<string> return_key = new List<string>();
            string Relay_file = ".\\xml";
            string Relay_name = "Relay.xml";
            string Relay_path = Relay_file+ "\\" + Relay_name;

            // Path to the folder with models extracted from `stanford-corenlp-3.4-models.jar`
            var jarRoot = @"stanford-corenlp-3.5.2-models\";

            // Annotation pipeline configuration
            var props = new java.util.Properties();
            props.setProperty("ner.useSUTime", "false");
            props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
            props.setProperty("sutime.binders", "0");

            // We should change current directory, so StanfordCoreNLP could find all the model files automatically
            var curDir = Environment.CurrentDirectory;
            System.IO.Directory.SetCurrentDirectory(jarRoot);
            var pipeline = new StanfordCoreNLP(props);
            System.IO.Directory.SetCurrentDirectory(curDir);

            // Annotation
            var annotation = new Annotation(sentence);
            pipeline.annotate(annotation);

            //輸出nlp分析結果至Relay.xml
            FileOutputStream os = new FileOutputStream(new File(Relay_file, Relay_name));
            pipeline.xmlPrint(annotation, os);
            os.close();

            //呼叫ner將單字組合為有意義的key組裝
            foreach(string k in ner(Relay_path))
            {
                return_key.Add(k);
            }

            return return_key;
        }
Example #6
0
 public void saveChunk(World world, Chunk chunk)
 {
     world.checkSessionLock();
     File file = chunkFileForXZ(chunk.xPosition, chunk.zPosition);
     if (file.exists())
     {
         WorldInfo worldinfo = world.getWorldInfo();
         worldinfo.func_22177_b(worldinfo.func_22182_g() - file.length());
     }
     try
     {
         var file1 = new File(saveDir, "tmp_chunk.dat");
         var fileoutputstream = new FileOutputStream(file1);
         var nbttagcompound = new NBTTagCompound();
         var nbttagcompound1 = new NBTTagCompound();
         nbttagcompound.setTag("Level", nbttagcompound1);
         storeChunkInCompound(chunk, world, nbttagcompound1);
         CompressedStreamTools.writeGzippedCompoundToOutputStream(nbttagcompound, fileoutputstream);
         fileoutputstream.close();
         if (file.exists())
         {
             file.delete();
         }
         file1.renameTo(file);
         WorldInfo worldinfo1 = world.getWorldInfo();
         worldinfo1.func_22177_b(worldinfo1.func_22182_g() + file.length());
     }
     catch (Exception exception)
     {
         exception.printStackTrace();
     }
 }
Example #7
0
    public static File extractResource(Class cls, string name, File directory, string prefix, string suffix)
    {
      InputStream resourceAsStream = cls.getResourceAsStream(name);
      if (resourceAsStream == null)
        return (File) null;
      File file = (File) null;
      int num1 = 0;
      IOException ioException1;
      try
      {
        if (prefix == null && suffix == null)
        {
          File.__\u003Cclinit\u003E();
          file = new File(directory, new File(name).getName());
          num1 = file.exists() ? 1 : 0;
        }
        else
          file = File.createTempFile(prefix, suffix, directory);
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        byte[] numArray = new byte[resourceAsStream.available()];
        int num2;
        while ((num2 = resourceAsStream.read(numArray)) > 0)
          fileOutputStream.write(numArray, 0, num2);
        resourceAsStream.close();
        fileOutputStream.close();
        goto label_14;
      }
      catch (IOException ex)
      {
        int num2 = 1;
        ioException1 = (IOException) ByteCodeHelper.MapException<IOException>((Exception) ex, (ByteCodeHelper.MapFlags) num2);
      }
      IOException ioException2 = ioException1;
      if (file != null && num1 == 0)
        file.delete();
      throw Throwable.__\u003Cunmap\u003E((Exception) ioException2);
label_14:
      return file;
    }