Code example for File

Methods: renameTo

0
 
    public void test_renameToLjava_io_File() { 
        String base = System.getProperty("java.io.tmpdir");
        File dir = new File(base, platformId);
        dir.mkdir();
        File f = new File(dir, "xxx.xxx");
        try { 
            f.renameTo(null);
            fail("Test 1: NullPointerException expected.");
        } catch (NullPointerException e) {
            // Expected. 
        } 
    } 
 
    public void test_toURL3() throws MalformedURLException { 
        File dir = new File(""); // current directory
        String newDirURL = dir.toURL().toString();
        assertTrue("Test 1: URL does not end with slash.",
                newDirURL.endsWith("/"));
    }