← Back to feed
Renewal·서른의 생활코딩

Ex2) Java I/O

NS
normalstory
cover image

import java.io.*;
 
public class FileTest {
public static void main( String[] args ) {
try {
// File object creation
File temp = new File( "C:/java", "temp" );
File tempFile = new File( "test" );
File fa = new File( "test.txt" );
// 디렉토리 생성
System.out.println( "create directory state : " + temp.mkdirs() );
System.out.println( "create directory state : " + tempFile.mkdir() );
// File에 관련된 method
System.out.println( "file canRead : " + fa.canRead() );
System.out.println( "temp canRead : " + temp.canRead() );
System.out.println( "temp canWrite : " + temp.canWrite() );
System.out.println( "temp getAbsoluteFile : " + temp.getAbsoluteFile() );
System.out.println( "temp getName : " + temp.getName() );
System.out.println( "temp getParent : " + temp.getParent() );
System.out.println( "temp getPath : " + temp.getPath() );
System.out.println( "temp isDirectory : " + temp.isDirectory() );
System.out.println( "temp isFile : " + temp.isFile() );
} catch ( Exception e ) {
}
}
}

This English version was translated by Claude.

친절한 찰쓰씨
Written by
친절한 찰쓰씨

Pleasant Charles — UI/UX researcher at AIT. Keeping notes on design, planning, and slow days here since 2010.