본문 바로가기

JAVA79

자바 로 xml 문서의 dom 파싱 이벤트 방식의 sax도 있으나 일단 제가 직접해서 제대로 돌아간것은 이것입니다. 일단 person.xml kiran pai 22 그리고 parsing 하는 클래스 입니다. package DCD;import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory;import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList;public class xmlTest { public static void main(String[] args){ try{ DocumentBuilderFactory.. 2009. 2. 12.
자바 폴더 삭제 자바 폴더 삭제 로직이다.(디렉토리까지 다 알아서 지워진다.) public boolean deleteFolder(File targetFolder){ File[] childFile = targetFolder.listFiles(); boolean confirm = false; int size = childFile.length; if (size > 0) { for (int i = 0; i < size; i++) { if (childFile[i].isFile()) { confirm = childFile[i].delete(); System.out.println(childFile[i]+":"+confirm + " 삭제"); } else { deleteFolder(childFile[i]); } } } targetFo.. 2009. 2. 11.
자바로 디렉토리 사이즈 보기 package test; import java.io.*;import VRS.util; public class FolderSizeCheck { /** * @param args */ long result = 0; //한개의 디렉토리를 확인하는데 클래스를 한번만 쓰면 되니까 //전역변수로 선언해서 클래스의 result 값을 찍어주면 됨 public static void main(String[] args) { // TODO Auto-generated method stub File f = new File("c:/test"); FolderSizeCheck fc = new FolderSizeCheck(); fc.checkSize(f); System.out.println(fc.result); //폴더 크기 찍어주기 }.. 2009. 1. 5.
[ JAVA ] 자바 base64 인코딩, 디코딩(String 일경우) package test;public class base64 { public static void main(String[] args){ String str = "abc"; String str1 = new sun.misc.BASE64Encoder().encode(str.getBytes()); //인코딩 System.out.println("str1===>"+str1); String str2 = ""; try{ str2 = new String(new sun.misc.BASE64Decoder().decodeBuffer(str1)); //디코딩 }catch(Exception e){ e.printStackTrace(); } System.out.println(str2); } } 2008. 12. 29.