Exemplo n.º 1
0
 public override void Close()
 {
     if (Out != null)
     {
         Out.close();
     }
 }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("ResultOfMethodCallIgnored") @Test public void begin_and_execute_periodic_commit_that_fails() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BeginAndExecutePeriodicCommitThatFails()
        {
            File file = File.createTempFile("begin_and_execute_periodic_commit_that_fails", ".csv").AbsoluteFile;

            try
            {
                PrintStream @out = new PrintStream(new FileStream(file, FileMode.Create, FileAccess.Write));
                @out.println("1");
                @out.println("2");
                @out.println("0");
                @out.println("3");
                @out.close();

                string url   = file.toURI().toURL().ToString().Replace("\\", "\\\\");
                string query = "USING PERIODIC COMMIT 1 LOAD CSV FROM \\\"" + url + "\\\" AS line CREATE ({name: 1/toInt(line[0])});";

                // begin and execute and commit
                HTTP.RawPayload payload  = quotedJson("{ 'statements': [ { 'statement': '" + query + "' } ] }");
                HTTP.Response   response = POST(TxCommitUri(), payload);

                assertThat(response.Status(), equalTo(200));
                assertThat(response, hasErrors(Org.Neo4j.Kernel.Api.Exceptions.Status_Statement.ArithmeticError));

                JsonNode message = response.Get("errors").get(0).get("message");
                assertTrue("Expected LOAD CSV line number information", message.ToString().Contains("on line 3. Possibly the last row committed during import is line 2. " + "Note that this information might not be accurate."));
            }
            finally
            {
                file.delete();
            }
        }
Exemplo n.º 3
0
        public virtual void saveJSGF(URL url)
        {
            PrintStream printStream = new PrintStream(new File(url.toURI()));

            printStream.print(this.toString());
            printStream.flush();
            printStream.close();
        }
        private void createInputFile(File file, string text, string text2)
        {
            File             file2            = new File(file, text);
            FileOutputStream fileOutputStream = new FileOutputStream(file2);
            PrintStream      printStream      = new PrintStream(fileOutputStream);

            printStream.println(text2);
            printStream.close();
        }
Exemplo n.º 5
0
        public static void showConfigAsHTML(ConfigurationManager ConfigurationManager, string path)
        {
            PrintStream printStream = new PrintStream(new FileOutputStream(path));

            HTMLDumper.dumpHeader(printStream);
            Iterator iterator = ConfigurationManager.getInstanceNames(ClassLiteral <Configurable> .Value).iterator();

            while (iterator.hasNext())
            {
                string text = (string)iterator.next();
                HTMLDumper.dumpComponentAsHTML(printStream, text, ConfigurationManager.getPropertySheet(text));
            }
            HTMLDumper.dumpFooter(printStream);
            printStream.close();
        }
Exemplo n.º 6
0
        public static void showConfigAsGDL(ConfigurationManager ConfigurationManager, string path)
        {
            PrintStream printStream = new PrintStream(new FileOutputStream(path));

            GDLDumper.dumpGDLHeader(printStream);
            Iterator iterator = ConfigurationManager.getInstanceNames(ClassLiteral <Configurable> .Value).iterator();

            while (iterator.hasNext())
            {
                string name = (string)iterator.next();
                GDLDumper.dumpComponentAsGDL(ConfigurationManager, printStream, name);
            }
            GDLDumper.dumpGDLFooter(printStream);
            printStream.close();
        }
Exemplo n.º 7
0
 public override void run()
 {
     try
     {
         FileOutputStream fileOutputStream = new FileOutputStream(this.filename);
         PrintStream      printStream      = new PrintStream(fileOutputStream);
         SearchState      initialState     = this.getLinguist().getSearchGraph().getInitialState();
         this.dumpSearchGraph(printStream, initialState);
         printStream.close();
     }
     catch (FileNotFoundException ex)
     {
         [email protected](new StringBuilder().append("Can't dump to file ").append(this.filename).append(' ').append(ex).toString());
     }
 }
Exemplo n.º 8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void dumpVmInfo(java.io.File directory) throws java.io.IOException
        public static void DumpVmInfo(File directory)
        {
            File        file = new File(directory, "main-vm-dump-" + DateTimeHelper.CurrentUnixTimeMillis());
            PrintStream @out = null;

            try
            {
                @out = new PrintStream(file);
                DumpVmInfo(@out);
            }
            finally
            {
                if (@out != null)
                {
                    @out.close();
                }
            }
        }
        public virtual void dumpAscii(string outputFile)
        {
            PrintStream printStream = new PrintStream(new FileOutputStream(outputFile), true);

            printStream.print(this.getNumberDataPoints());
            printStream.print(' ');
            Iterator iterator = this.allFeatures.iterator();

            while (iterator.hasNext())
            {
                float[] array  = (float[])iterator.next();
                float[] array2 = array;
                int     num    = array2.Length;
                for (int i = 0; i < num; i++)
                {
                    float num2 = array2[i];
                    printStream.print(num2);
                    printStream.print(' ');
                }
            }
            printStream.close();
        }
Exemplo n.º 10
0
 public override void close()
 {
     base.close();
     _second.close();
 }
Exemplo n.º 11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void main(String[] args) throws IOException
        public static void Main(string[] args)
        {
            Scanner inputReader = new Scanner(Console.In);

            // Get the inputs
            Console.WriteLine("Player Name: ");
            string inputName = inputReader.next();

            Console.WriteLine("What is the new Score: ");
            int inputScore = inputReader.Next();

            File myFile = new File("newHighScore.txt");

            if (myFile.exists())
            {
                myFile.delete();
            }

            myFile.createNewFile();
            PrintStream stream = new PrintStream(myFile);

            File userFile = new File("HighScore.txt");

            if (userFile.exists())
            {
                int     playerCount = 0;
                Scanner fileReader  = new Scanner(userFile);
                while (fileReader.hasNext())
                {
                    string playerName  = fileReader.next();
                    int    playerScore = fileReader.Next();
                    // Check if the new score is higher than this player score
                    if (inputScore > playerScore)
                    {
                        stream.println(inputName + " " + inputScore);
                        playerCount++;
                        // Set inputScore to 0 so that it will not come in here again
                        inputScore = 0;
                    }

                    // Check that we only write for 5 players
                    if (playerCount < 5)
                    {
                        stream.println(playerName + " " + playerScore);
                        playerCount++;
                    }
                }
                stream.flush();
                stream.close();

                fileReader.close();
            }

            File backupFile = new File("backupHighScore.txt");

            if (backupFile.exists())
            {
                backupFile.delete();
            }

            userFile.renameTo(backupFile);

            myFile.renameTo(userFile);

            // verify content
            Scanner reader = new Scanner(userFile);

            while (reader.hasNextLine())
            {
                Console.WriteLine(reader.nextLine());
            }
            reader.close();
        }