File papers to create an example

Author:Anonymous    Updated:2008-10-26 21:21:40
File a document creating the most basic example of record:

import java.io. *;
public class TestFile (
public static void main (String [] args)
(
String filename = "test.txt"; / / File Name
String directory = "testa / testb"; / / path name
File f = new File (directory, filename); / / Object File Structure

if (f.exists ())
(
System.out.println ( "File name:" + f.getAbsolutePath ());
System.out.println ( "File size:" + f.length ());
) else (
f.getParentFile (). mkdirs ();// create a series of path
try (
f.createNewFile ();
) catch (IOException e) (
e.printStackTrace ();
)
)
)
)
Previous:Java in the understanding of static
Next:Realizes Java using Stripes the Web development
User Reviews
Site Search
Recommended article
AD