import java.io.File;
import java.io.IOException;

public class FileTest {
 public static void main(String[] args) {
  File f = new File("c:/");
  String contents[] = f.list();
  
  for(int i=0; i<contents.length; i++){
   File tf = new File(f, contents[i]);
   
   if(tf.isDirectory()){
    System.out.println(tf.getName()+" is Directory!!");
   } else {
    System.out.println(tf.getName()+"  File' length is " + tf.length()+" Bytes");
   }
   
  }
  
  
//  File f = new File("C:/selog.txt");
//  System.out.println("cna read?" + f.canRead());
//  System.out.println("cna write?" + f.canWrite());
//  System.out.println("cna execute?" + f.canExecute());
//  
//  File newFile = new File("d:/test.txt");
//  
//  try {
//   System.out.println("new File?" + f.createNewFile());
//  } catch (IOException e) {
//   e.printStackTrace();
//  }
//  
//  
//  try {
//   System.out.println("new File?" + newFile.createNewFile());
//  } catch (IOException e) {
//   e.printStackTrace();
//  }
 }

}

'2020년도 이전 > 입출력' 카테고리의 다른 글

파일 읽고, 쓰기 - 자바 파일 복사  (0) 2013.07.09
파일 읽기....  (0) 2013.07.09
알파벳 입력하면 아스키코드 출력  (0) 2013.07.09

+ Recent posts