Code example for PrintStream

Methods: flush, printf

0
    /** 
     * @tests java.io.PrintStream#printf(java.util.Locale, java.lang.String, 
     *        java.lang.Object...) 
     */ 
    public void test_printfLjava_util_Locale_Ljava_lang_String_$Ljava_lang_Object() { 
        PrintStream os = new PrintStream(bos, false);
        os.printf(Locale.US, "%s %s", "Hello", "World");
        os.flush();
        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        byte[] rbytes = new byte[11];
        bis.read(rbytes, 0, rbytes.length);
        assertEquals("Wrote incorrect string", "Hello World",
                new String(rbytes));
    } 
 
	@Override 
	protected void setUp() throws Exception {		 
		super.setUp(); 
		testFile = File.createTempFile("test", null);
		testFilePath = testFile.getAbsolutePath();
	}