'java 파일 인코딩'에 해당되는 글 1건

  1. 2010.06.10 java 파일 인코딩 문제

/*// 1. 파일 인코딩 확인
   FileInputStream fis = new FileInputStream(args[0]);

   // 2. 파일 읽기 (4Byte)
   byte[] BOM = new byte[4];
   fis.read(BOM, 0, 4);

   // 3. 파일 인코딩 확인하기
   if( (BOM[0] & 0xFF) == 0xEF && (BOM[1] & 0xFF) == 0xBB && (BOM[2] & 0xFF) == 0xBF )
    System.out.println("UTF-8");
   else if( (BOM[0] & 0xFF) == 0xFE && (BOM[1] & 0xFF) == 0xFF )
    System.out.println("UTF-16BE");
   else if( (BOM[0] & 0xFF) == 0xFF && (BOM[1] & 0xFF) == 0xFE )
    System.out.println("UTF-16LE");
   else if( (BOM[0] & 0xFF) == 0x00 && (BOM[1] & 0xFF) == 0x00 &&
            (BOM[0] & 0xFF) == 0xFE && (BOM[1] & 0xFF) == 0xFF )
    System.out.println("UTF-32BE");
   else if( (BOM[0] & 0xFF) == 0xFF && (BOM[1] & 0xFF) == 0xFE &&
            (BOM[0] & 0xFF) == 0x00 && (BOM[1] & 0xFF) == 0x00 )
    System.out.println("UTF-32LE");
   else
    System.out.println("EUC-KR");

   String fileEncoding=System.getProperty("file.encoding");
   System.out.println("file.encoding = "+fileEncoding);*/

   //FileReader input = new FileReader(args[0]);
   //BufferedReader bufRead = new BufferedReader(input);

   InputStream is=new FileInputStream(args[0]);
   BufferedReader bufRead = new BufferedReader(new InputStreamReader(is, "EUC-KR"));


mcpaint.tistory.com/88

Posted by [czar]
,