Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void addTo(String line, String... path) throws java.io.IOException
        internal virtual void AddTo(string line, params string[] path)
        {
            FileObject fo  = processingEnv.Filer.getResource(StandardLocation.CLASS_OUTPUT, "", path(path));
            URI        uri = fo.toUri();
            File       file;

            try
            {
                file = new File(uri);
            }
            catch (Exception)
            {
                file = new File(uri.ToString());
            }
            if (file.exists())
            {
                foreach (string previous in _nl.split(fo.getCharContent(true), 0))
                {
                    if (line.Equals(previous))
                    {
                        return;
                    }
                }
            }
            else
            {
                file.ParentFile.mkdirs();
            }

            using (PrintWriter writer = new PrintWriter(new StreamWriter(new FileStream(file, true), Encoding.UTF8)))
            {
                writer.append(line).append("\n");
            }
        }