반응형
package ase;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.AlgorithmParameters;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.InvalidParameterSpecException;
import java.security.spec.KeySpec;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;

public class AES128_File {

	public static String byteToHex(byte[] raw) {

		String HEXES = "0123456789ABCDEF";

		if (raw == null) {
			return null;
		}
		final StringBuilder hex = new StringBuilder(2 * raw.length);
		for (final byte b : raw) {
			hex.append(HEXES.charAt((b & 0xF0) >> 4)).append(HEXES.charAt((b & 0x0F)));
		}
		return hex.toString();
	}

	public static byte[] hexToByte(String hexString) {
		int len = hexString.length();

		byte[] ba = new byte[len / 2];

		for (int i = 0; i < len; i += 2) {
			ba[i / 2] = (byte) ((Character.digit(hexString.charAt(i), 16) << 4) + Character.digit(hexString.charAt(i + 1), 16));
		}

		return ba;
	}

	/**
	 * @param msg
	 */
	private void cryptMessage(String msg) {
		System.out.println("** Crypt ** " + msg);
	}
	/**
	 * @param input
	 *            - the cleartext file to be encrypted
	 * @param output
	 *            - the encrypted data file
	 * @throws IOException
	 * @throws IllegalBlockSizeException
	 * @throws BadPaddingException
	 */
	public void WriteEncryptedFile(String cryptKey,InputStream inputStream, OutputStream outputStream) throws IOException, IllegalBlockSizeException, BadPaddingException {
		try {
			

			int SALT_LEN = 8;
			byte[] mInitVec = null;
			byte[] mSalt = new byte[SALT_LEN];
			Cipher mEcipher = null;
			int KEYLEN_BITS = 128; // see notes below where this is used.
			int ITERATIONS = 65536;
			int MAX_FILE_BUF = 2048;

			long totalread = 0;
			int nread = 0;
			byte[] inbuf = new byte[MAX_FILE_BUF];
			SecretKeyFactory factory = null;
			SecretKey tmp = null;

			mSalt = new byte[SALT_LEN];
			SecureRandom rnd = new SecureRandom();
			
			rnd.nextBytes(mSalt);
			cryptMessage("generated salt :" + byteToHex(mSalt));
			factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");

			KeySpec spec = new PBEKeySpec(cryptKey.toCharArray(), mSalt, ITERATIONS, KEYLEN_BITS);

			tmp = factory.generateSecret(spec);

			SecretKey secret = new SecretKeySpec(tmp.getEncoded(), "AES");

			mEcipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
			mEcipher.init(Cipher.ENCRYPT_MODE, secret);

			AlgorithmParameters params = mEcipher.getParameters();

			mInitVec = params.getParameterSpec(IvParameterSpec.class).getIV();

			System.out.println("mInitVec : " + mInitVec);
			cryptMessage("mInitVec is :" + byteToHex(mInitVec));
			outputStream.write(mSalt);
			outputStream.write(mInitVec);

			while ((nread = inputStream.read(inbuf)) > 0) {
				cryptMessage("read " + nread + " bytes");
				totalread += nread;

				byte[] trimbuf = new byte[nread];

				for (int i = 0; i < nread; i++) {
					trimbuf[i] = inbuf[i];
				}

				byte[] tmpBuf = mEcipher.update(trimbuf);

				if (tmpBuf != null) {
					outputStream.write(tmpBuf);
				}
			}

			byte[] finalbuf = mEcipher.doFinal();

			if (finalbuf != null) {
				outputStream.write(finalbuf);
			}

			outputStream.flush();
			inputStream.close();
			outputStream.close();
			outputStream.close();
			cryptMessage("wrote " + totalread + " encrypted bytes");
			System.out.println("파일 암호화 성공");
		} catch (InvalidKeyException ex) {
			Logger.getLogger(AES128_File.class.getName()).log(Level.SEVERE, null, ex);
		} catch (InvalidParameterSpecException ex) {
			Logger.getLogger(AES128_File.class.getName()).log(Level.SEVERE, null, ex);
		} catch (NoSuchAlgorithmException ex) {
			Logger.getLogger(AES128_File.class.getName()).log(Level.SEVERE, null, ex);
		} catch (NoSuchPaddingException ex) {
			Logger.getLogger(AES128_File.class.getName()).log(Level.SEVERE, null, ex);
		} catch (InvalidKeySpecException ex) {
			Logger.getLogger(AES128_File.class.getName()).log(Level.SEVERE, null, ex);
		}
		
	}

	/**
	 * Read from the encrypted file (input) and turn the cipher back into
	 * cleartext. Write the cleartext buffer back out to disk as (output) File.
	 * 
	 * I left CipherInputStream in here as a test to see if I could mix it with
	 * the update() and final() methods of encrypting and still have a correctly
	 * decrypted file in the end. Seems to work so left it in.
	 * 
	 * @param input
	 *            - File object representing encrypted data on disk
	 * @param output
	 *            - File object of cleartext data to write out after decrypting
	 * @throws IllegalBlockSizeException
	 * @throws BadPaddingException
	 * @throws IOException
	 */
	public void ReadEncryptedFile(String cryptKey,InputStream inputStream, OutputStream outputStream) throws IllegalBlockSizeException, BadPaddingException, IOException {
		try {

			int SALT_LEN = 8;
			byte[] mInitVec = null;
			byte[] mSalt = new byte[SALT_LEN];
			Cipher mDecipher = null;
			int KEYLEN_BITS = 128; // see notes below where this is used.
			int ITERATIONS = 65536;
			int MAX_FILE_BUF = 2048;

			CipherInputStream cin;
			long totalread = 0;
			int nread = 0;
			byte[] inbuf = new byte[MAX_FILE_BUF];

			SecretKeyFactory factory = null;
			SecretKey tmp = null;
			// SecretKey secret = null;
			

			// Read the Salt
			inputStream.read(mSalt);
			cryptMessage("generated salt :" + byteToHex(mSalt));

			factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");

			KeySpec spec = new PBEKeySpec(cryptKey.toCharArray(), mSalt, ITERATIONS, KEYLEN_BITS);

			tmp = factory.generateSecret(spec);

			SecretKey secret = new SecretKeySpec(tmp.getEncoded(), "AES");

			mDecipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
			mDecipher.init(Cipher.ENCRYPT_MODE, secret);

			AlgorithmParameters params = mDecipher.getParameters();
			mInitVec = params.getParameterSpec(IvParameterSpec.class).getIV();

			inputStream.read(mInitVec);
			cryptMessage("mInitVec is :" + byteToHex(mInitVec));
			mDecipher.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(mInitVec));

			cin = new CipherInputStream(inputStream, mDecipher);

			System.out.println("inbuf.length : " + inbuf.length);

			while ((nread = cin.read(inbuf)) > 0) {
				// Db("read " + nread + " bytes");
				totalread += nread;

				byte[] trimbuf = new byte[nread];

				for (int i = 0; i < nread; i++) {
					trimbuf[i] = inbuf[i];
				}

				// write out the size-adjusted buffer
				outputStream.write(trimbuf);
			}

			outputStream.flush();
			cin.close();
			inputStream.close();
			outputStream.close();
			cryptMessage("wrote " + totalread + " encrypted bytes");
		} catch (Exception ex) {
			ex.getStackTrace();
			Logger.getLogger(AES128_File.class.getName()).log(Level.SEVERE, null, ex);
		}
	}

	/**
	 * adding main() for usage demonstration. With member vars, some of the
	 * locals would not be needed
	 */
	public static void main(String[] args) {

		// create the input.txt file in the current directory before continuing
		File input = new File("C:\\Test\\test.txt");
		File eoutput = new File("C:\\Test\\test.aes");
		File doutput = new File("C:\\Test\\decrypted1.txt");
		String iv = null;
		String salt = null;
		AES128_File aesFile = new AES128_File();
		
		String cryptKey = "1q2w3e";

		/*
		 * write out encrypted file
		 */
		try {
			aesFile.WriteEncryptedFile(cryptKey,new FileInputStream(input), new FileOutputStream(eoutput));
			System.out.printf("File encrypted to " + eoutput.getName() + "\niv:" + iv + "\nsalt:" + salt + "\n\n");
		} catch (IllegalBlockSizeException | BadPaddingException | IOException e) {
			e.printStackTrace();
		}

		/*
		 * decrypt file
		 */
		/*
		 * write out decrypted file
		 */
		try {
			aesFile.ReadEncryptedFile(cryptKey,new FileInputStream(eoutput), new FileOutputStream(doutput));
			System.out.println("decryption finished to " + doutput.getName());
		} catch (IllegalBlockSizeException | BadPaddingException | IOException e) {
			e.printStackTrace();
		}
	}
}


반응형


public class ShowDefaultDalog extends JDialog implements WindowListener {

	private static final long serialVersionUID = 1L;

	/*
	 * imageHeight : 이미지 세로값 imageWidth : 이미지 가로값
	 */
	private static int imageHeight = 30;
	private static int imageWidth = 30;

	private JPanel jDalog_Main_Panel;
	private JPanel jDalog_North_Panel;
	private JPanel jDalog_Center_Panel;
	private JPanel jDalog_South_Panel;
	private JPanel jDalog_West_Panel;
	private JPanel jDalog_East_Panel;

	private JButton yes_Btn;
	private JButton no_Btn;
	private JButton wait_Btn;
	private String yseBtnText;
	private String noBtnText;
	private String waitBtnText;

	private String imagePath;
	private String message;

	private int type;
	private int result;

	/**
	 * 기본 다이얼로그설정
	 * 
	 * @author Leesangjun
	 * @param title
	 *            타이틀 message 다이얼로그 메시지, imagePath 설정 이미지 Path, type : 1,2,3 버튼 갯수
	 * @return 객체 생성
	 */
	public ShowDefaultDalog(String title, String message, String imagePath, int type) {
		this.message = message;
		this.imagePath = imagePath;
		this.type = type;
		setTitle(title);
	}

	/**
	 * 기본 다이얼로그설정
	 * 
	 * @author Leesangjun
	 * @return Dialog View
	 */
	public void createView() {

		createNorthPanel();
		createCenterPanel();
		createSouthPanel();
		createWestPanel();
		createEastPanel();

		jDalog_Main_Panel = new JPanel();
		jDalog_Main_Panel.setLayout(new BorderLayout());
		jDalog_Main_Panel.add("North", jDalog_North_Panel);
		jDalog_Main_Panel.add("Center", jDalog_Center_Panel);
		jDalog_Main_Panel.add("South", jDalog_South_Panel);
		jDalog_Main_Panel.add("West", jDalog_West_Panel);
		jDalog_Main_Panel.add("East", jDalog_East_Panel);

		addWindowListener(this);
		setAlwaysOnTop(true);
		setResizable(false);
		setModal(true);
		setType(Type.POPUP);
		add(jDalog_Main_Panel);
		pack();

		Dimension frameSize = getSize();
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
	}

	private void createNorthPanel() {
		jDalog_North_Panel = new JPanel();
		jDalog_North_Panel.setPreferredSize(new Dimension(0, 5));
	}

	private void createCenterPanel() {
		jDalog_Center_Panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JPanel center = new JPanel();
		ImagePanel imagePanel = new ImagePanel(new ImageIcon(getImagePath()).getImage());
		imagePanel.setHeight(imageHeight);
		imagePanel.setWidth(imageWidth);
		imagePanel.setPreferredSize(new Dimension(imageWidth, imageHeight));
		JLabel label = new JLabel(getMessage());
		JPanel messagePanel = new JPanel();
		messagePanel.add(label);
		center.add(imagePanel);
		center.add(messagePanel);
		jDalog_Center_Panel.add(center);
	}

	private void createWestPanel() {
		jDalog_West_Panel = new JPanel();
		jDalog_West_Panel.setPreferredSize(new Dimension(5, 0));
	}

	private void createSouthPanel() {
		jDalog_South_Panel = new JPanel();

		String btnText = "";

		if (yseBtnText == null) {
			btnText = UICode.DEFAULT_DIALOG_BUTTON_YES;
		} else {
			btnText = yseBtnText;
		}
		yes_Btn = new JButton(btnText);

		if (noBtnText == null) {
			btnText = UICode.DEFAULT_DIALOG_BUTTON_NO;
		} else {
			btnText = noBtnText;
		}
		no_Btn = new JButton(btnText);

		if (waitBtnText == null) {
			btnText = UICode.DEFAULT_DIALOG_BUTTON_WAIT;
		} else {
			btnText = waitBtnText;
		}
		wait_Btn = new JButton(btnText);

		switch (type) {
		case 1:
			jDalog_South_Panel.add(yes_Btn);
			break;
		case 2:
			jDalog_South_Panel.add(yes_Btn);
			jDalog_South_Panel.add(no_Btn);
			break;
		case 3:
			jDalog_South_Panel.add(yes_Btn);
			jDalog_South_Panel.add(no_Btn);
			jDalog_South_Panel.add(wait_Btn);
			break;
		default:
			break;
		}
		yes_Btn.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				result = 1;
				setVisible(false);
			}
		});

		no_Btn.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				result = 2;
				setVisible(false);

			}
		});
		
		wait_Btn.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				result = 3;
				setVisible(false);
				
			}
		});

	}

	private void createEastPanel() {
		jDalog_East_Panel = new JPanel();
	}

	public String getImagePath() {
		return imagePath;
	}

	public void setImagePath(String imagePath) {
		this.imagePath = imagePath;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public int getResult() {
		return result;
	}

	public void setYseBtnText(String yseBtnText) {
		this.yseBtnText = yseBtnText;
	}

	public void setNoBtnText(String noBtnText) {
		this.noBtnText = noBtnText;
	}

	public void setWaitBtnText(String waitBtnText) {
		this.waitBtnText = waitBtnText;
	}

	@Override
	public void windowOpened(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowClosing(WindowEvent e) {
		// TODO Auto-generated method stub
		result = 2;
		setVisible(false);

	}

	@Override
	public void windowClosed(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowIconified(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowDeiconified(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowActivated(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowDeactivated(WindowEvent e) {
		// TODO Auto-generated method stub

	}

}


////////////////////////////////////////////////////////

//호출시

///////////////////////////////////////////////////////

String message = "길이길이길이길이ㅁㄴㅇㅁㄴㅇㅁㄴㅇㅁㄴㅇㅂㅈㄷㅂㅈㄷㅂㅈㄷㅂㅈㄷㅂㅈㄷㅂㅈㄷㅂㅈㄷㅂㅈㄷㅂㅈㄷㅂㅈㄷ";
String imagePath = "image/tray.png";
ShowDefaultDalog frame = new ShowDefaultDalog("타이틀!!", message, imagePath, 3);
frame.setYseBtnText("asd");

frame.createView();
frame.setVisible(true);

System.out.println("결과값: " + frame.getResult());




'JAVA > Java' 카테고리의 다른 글

eclipse에 github 연결해서 웹저장소에서 버전관리(repository)하기  (0) 2016.05.20
AES128 파일 암복호화  (0) 2016.05.20
AES, SHA256 암 복호화  (0) 2016.03.02
java String Calss  (0) 2015.03.18
[JAVA] SocketServer  (0) 2014.11.18
반응형

package co.kr.s3i.common;

import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

import org.apache.commons.codec.binary.Base64;

public class AES256Util {

	private String REAL_KEY = "KEY";

	private String iv;
	private Key keySpec;

	private String SHA256(String key) {
		String SHA = "";
		try {
			MessageDigest sh = MessageDigest.getInstance("SHA-256");
			sh.update(key.getBytes());
			byte byteData[] = sh.digest();
			StringBuffer sb = new StringBuffer();
			for (int i = 0; i < byteData.length; i++) {
				sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
			}
			SHA = sb.toString();

		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
			SHA = null;
		}
		return SHA;
	}

	public AES256Util() throws UnsupportedEncodingException {
		String key = SHA256(REAL_KEY);
		this.iv = key.substring(0, 16);

		byte[] keyBytes = new byte[16];
		byte[] b = key.getBytes("UTF-8");
		int len = b.length;
		if (len > keyBytes.length)
			len = keyBytes.length;
		System.arraycopy(b, 0, keyBytes, 0, len);
		SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");

		this.keySpec = keySpec;
	}

	// 암호화
	public String aesEncode(String str) throws java.io.UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException,
			InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException {
		
		if(!BaseCode.isAES256_CHECK){
			return str;
		}
		
		Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding");
		c.init(Cipher.ENCRYPT_MODE, keySpec, new IvParameterSpec(iv.getBytes()));

		byte[] encrypted = c.doFinal(str.getBytes("UTF-8"));
		String enStr = new String(Base64.encodeBase64(encrypted));
		
		return enStr;
	}

	// 복호화
	public String aesDecode(String str) throws java.io.UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException,
			InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException {
		
		if(!BaseCode.isAES256_CHECK){
			return str;
		}
		
		Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding");
		c.init(Cipher.DECRYPT_MODE, keySpec, new IvParameterSpec(iv.getBytes("UTF-8")));
		byte[] byteStr = Base64.decodeBase64(str.getBytes());

		return new String(c.doFinal(byteStr), "UTF-8");
	}

}



'JAVA > Java' 카테고리의 다른 글

AES128 파일 암복호화  (0) 2016.05.20
JAVA swing custum Dialog 만들기  (0) 2016.05.20
java String Calss  (0) 2015.03.18
[JAVA] SocketServer  (0) 2014.11.18
[JAVA] JFrame 이용하여 Mysql 접속 후 프로그램 생성  (0) 2014.11.18
반응형


자바/Java String클래스 생성자와 메서드 정리

 
1. substring
String substring(int begin)
String substring(int begin, int end)
한 문자열에서 내용의 일부를 추출하는 메서드
주어진 시작위치(begin)부터 끝 위치(end) 범위에 포함된 문자열을 얻는다.
 

String s = "java.lang.Object";
String c = s.substring(10);          c = "Object"
String p = s.substring(5,9);         p = "lang"
 
substring(int start , int end)를 사용할 때 주의해야할 점은 매개변수로 사용되는 문자열에서 각 문자의 위치를 뜻하는 index가 0부터 시작한다는 것과 start부터 end의 범위 중 end위치에 있는 문자는 결과에 포함되지 않는다는 것이다.

(start <= x < end) 


[참고] end에서 start값을 빼면 substring에 의해 추출될 글자의 수가 된다.
[참고] substring의 철자에 주의하도록 한다. subString이 아니다. 

index  0 1 2 3 4 5 6 7 8 9  
char   H e l  l  o .  j a v a   


사용예                                                  결과 
string a = str.substring(0,5);                a = "hello"
string b = str.substring(6.10);               b = "java"


2.split
String[] split(String regex)
문자열을 지정된 분리자(regex)로 나누어 문자열 배열에 담아 반환 한다.

String animals = "dog, cat, bear";
String[] arr = animals.split(",")

결과
arr[0] = "dog"
arr[1] = "cat"
arr[2] = "bear"
 

3. contains
boolean contains(charSequence s)
지정된 문자열(s)이 포함되었는지 검사 한다.

String s = "abcedfg";
boolean b = s.contains("bc");

결과
b = true
 

4. endsWith
boolean endsWith(String suffix) 
지정된 문자열(suffix)로 끝나는지 검사 한다.

String file = "Hello.txt";
boolean b = file.endsWith("txt");

결과
b = true 
 


5. equals
boolean equals(Object obj)
매개변수로 받은 문자열(obj)과 String인스턴스의 문자열을 비교한다. obj가 String이 아니거나 문자열이 다르면 false를 반환한다. String 클래스는 equals 메소드를 오버라이드 해서 사용한다.

String s = "Hello";
boolean b = s.equals("Hello");
boolean b2 = s.equals("hello");

결과
b = true
b2 = false

  

6.replace
String replace(CharSequence old, CharSequence nw)
문자열 중의 문자열(old)을 새로운 문자열(nw)로 모두 바꾼 문자열을 반환 한다.


String s = "Hellollo";
String sl = s.replace("ll","LL"));

결과
sl = "HeLLoLLo"


7.toString
String toString()
String 인스턴스에 저장되어 있는 문자열을 반환 한다.


String s = "Hello";
String sl = s.toString();

결과
sl = "Hello"


8. toLowerCase
String toLoweCase()
String 인스턴스에 저장되어있는 모든 문자열을 소문자로 변환하여 반환 한다.


String s = "Hello";
String sl = s.toLowerCase();

결과
sl = "Hello"


9. toUpperCase
String toUpperCase()
String 인스턴스에 저장되어있는 모든 문자열을 대문자로 변환하여 반환 한다. 


String s = "Hello";
String sl = s.toUpperCase(); 

결과
sl = "HELLO"


10. trim
String trim()
문자열의 왼쪽 끝과 오른쪽 끝에 있는 공백을 없앤 결과를 반환한다. 이 때 문자열 중간에 있는 공백은 제거되지 않는다.


String s = "     Hello World   ";
String sl = s.trim();

결과
sl = "Hello World"


11. valueOf
static String valueOf(boolean b)
static String valueOf(char c) 
static String valueOf(int i) 
static String valueOf(long l) 
static String valueOf(float  f) 
static String valueOf(double d) 
static String valueOf(Object o) 
지정된 값을 문자열로 변환하여 반환 한다.
참조변수의 경우, toString()을 호출한 결과를 반환 한다.


String b = String.valueOf(true);
String c = String.valueOf('a'); 
String i = String.valueOf(100); 
String l = String.valueOf(100L); 
String f = String.valueOf(10f); 
String d = String.valueOf(10.0);
java.util.Date dd = new java.util.Date();
String date = String.valueOf(dd);

결과
b = "true"
c = "a"
i = "100"
l = "100"
f = "10.0"
d = "10.0"
date = "Sub Jan 27:21:26:29 KST 2008"
  





출처 : 자바의정석 

'JAVA > Java' 카테고리의 다른 글

JAVA swing custum Dialog 만들기  (0) 2016.05.20
AES, SHA256 암 복호화  (0) 2016.03.02
[JAVA] SocketServer  (0) 2014.11.18
[JAVA] JFrame 이용하여 Mysql 접속 후 프로그램 생성  (0) 2014.11.18
[JAVA] Mysql DB 접속하기(Connect)  (0) 2014.11.18
반응형
import java.io.*;
import java.net.*;

public class SocketServer {

	public static void main(String[] args) {

		try {
			// 서버에서 사용할 포트 번호
			int portNumber = 11001;

			ServerSocket aServersocket = new ServerSocket(portNumber);

			System.out.println("서버 소켓 준비 완료");

			while (true) {
				// 클라이언트의 요청이 올때까지 대기하다가
				// 클라이언트의 요청이 오면 그 정보를 저장
				Socket aSocket = aServersocket.accept();

				// 접속한 클라이언트의 주소 정보를 저장
				InetAddress client = aSocket.getInetAddress();
				// 클라이언트의 주소 정보 출력
				System.out.println(client);

				// 클라이언트가 보낸 객체를 확인하기 위한 스트림 생성

				ObjectInputStream ois = new ObjectInputStream(
						aSocket.getInputStream());

				// 데이터 1개 읽기
				Object obj = ois.readObject();
				// 데이터 출력
				System.out.println("보낸 데이터 : " + obj);

				// 클라이언트에게 객체를 전송하기 위한 스트림을 생성

				ObjectOutputStream oos = new ObjectOutputStream(
						aSocket.getOutputStream());
				
				oos.writeObject("서버에서 전송한 메시지");
				oos.flush();
				//클라이언트와 연결된 소켓 닫기
				aSocket.close();

			}

		} catch (Exception e) {

		}

	}

}

반응형

JFrame을 이용하여 폼을 만든 후 Mysql DB에 접속하여 select, insert, delete 을 해보자!!



CustomerDBUse.java


package CustomerDB;

import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;

import javax.print.attribute.standard.*;
import javax.swing.*;
import javax.swing.table.*;

public class CustomerDBUse extends JFrame implements ActionListener {

	JPanel panWest;
	JPanel panSouth;

	// 레이블과 텍스트 필드를 묶어서 panWest에 배치될 패널
	JPanel p1, p2, p3, p4;

	// 텍스트 필드
	JTextField txtName, txtEmail, txtTel;

	// 아래쪽의 버튼
	JButton btnTotal, btnAdd, btnDel, btnSearch, btnCancel;

	// 데이터를 출력할 테이블
	JTable table;

	// 누른 버튼의 이름을 기억하기 위한 상수 선언 및 변수 선언
	private static final int NONE = 0;
	private static final int ADD = 1;
	private static final int DELETE = 2;
	private static final int SEARCH = 3;
	private static final int TOTAL = 4;

	int cmd = NONE;

	// 데이터베이스 연결을 저장할 변수
	Connection con;

	// sql 수행을 위한 변수
	Statement stmt;
	PreparedStatement pstmtInsert;
	PreparedStatement pstmtDelete;

	// 데이터베이스 연결 클래스 이름과 위치 및 아이디와 패스워드 저장
	private String driver = "oracle.jdbc.driver.OracleDriver";
	private String url = "jdbc:oracle:thin:@211.183.0.100:1521:orcl";
	private String user = "user12";
	private String pwd = "user12";

	// 데이터베이스 접속하는 메서드

	private void dbConnect() {
		try {
			Class.forName(driver);
			con = DriverManager.getConnection(url, user, pwd);
			stmt = con.createStatement();
			JOptionPane.showMessageDialog(this, "접속 성공");
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());
		}

	}

	private String sqlInsert = "insert into customer2 values(id_sequence.nextval,?,?,?,sysdate)";

	private String sqlDelete = "delete from customer2 where name = ?";

	PreparedStatement pstmtTotal;
	private String sqlTotal = "select * from customer2";

	PreparedStatement pstmtSearch;
	private String sqlSearch = "select * from customer2 where name =?";

	// 생성자 - 화면 구성과 이벤트 연결
	public CustomerDBUse() {
		dbConnect();
		panWest = new JPanel(new GridLayout(5, 0));

		p1 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
		p1.add(new JLabel("이 름"));
		p1.add(txtName = new JTextField(12));
		panWest.add(p1);

		p2 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
		p2.add(new JLabel("이 메 일"));
		p2.add(txtEmail = new JTextField(12));
		panWest.add(p2);

		p3 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
		p3.add(new JLabel("전화번호"));
		p3.add(txtTel = new JTextField(12));
		panWest.add(p3);

		p4 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
		p4.add(new JLabel(" "));
		panWest.add(p4);

		add(panWest, "West");

		panSouth = new JPanel();
		panSouth.add(btnTotal = new JButton("전체보기"));
		panSouth.add(btnAdd = new JButton("추 가"));
		panSouth.add(btnDel = new JButton("삭 제"));
		panSouth.add(btnSearch = new JButton("검 색"));
		panSouth.add(btnCancel = new JButton("취 소"));
		add(panSouth, "South");

		// 테이블을 생성해서 부착
		add(new JScrollPane(table = new JTable()), "Center");

		// 텍스트 필드를 사용할 수 없도록 설정
		txtEmail.setEditable(false);
		txtName.setEditable(false);
		txtTel.setEditable(false);

		setDefaultCloseOperation(EXIT_ON_CLOSE);

		setTitle("데이터베이스 연동");
		setBounds(100, 100, 500, 250);
		setVisible(true);

		btnAdd.addActionListener(this);
		btnTotal.addActionListener(this);
		btnDel.addActionListener(this);
		btnSearch.addActionListener(this);
		btnCancel.addActionListener(this);

		this.addWindowListener(new WindowAdapter() {

			public void windowClosing(WindowEvent e) {
				try {
					if (con != null) {
						con.close();
					}
				} catch (Exception e1) {

				}
			}
		});

	}

	// 사용자가 작업을 위해서 버튼을 처음 눌렀을 때 호출되서
	// 버튼의 활성화 여부를 설정하는 사용자 정의 메서드
	private void setButton(int command) {
		// 취소 버튼을 제외한 버튼 비 활성화
		btnTotal.setEnabled(false);
		btnAdd.setEnabled(false);
		btnCancel.setEnabled(false);
		btnDel.setEnabled(false);
		btnSearch.setEnabled(false);

		switch (command) {
		case ADD: {
			btnAdd.setEnabled(true);
			cmd = ADD;
			break;
		}
		case DELETE: {
			btnDel.setEnabled(true);
			cmd = DELETE;
			break;
		}
		case TOTAL: {
			btnTotal.setEnabled(true);
			cmd = TOTAL;
			break;
		}
		case SEARCH: {
			btnSearch.setEnabled(true);
			cmd = SEARCH;
			break;
		}
		case NONE: {
			btnTotal.setEnabled(true);
			btnAdd.setEnabled(true);
			btnCancel.setEnabled(true);
			btnDel.setEnabled(true);
			btnSearch.setEnabled(true);
			cmd = NONE;
			break;
		}
		default:
			break;
		}
	}

	private void setText(int command) {
		switch (command) {
		case ADD: {
			txtName.setEditable(true);
			txtEmail.setEditable(true);
			txtTel.setEditable(true);
			break;
		}
		case DELETE: {
			txtName.setEditable(true);
			txtEmail.setEditable(false);
			txtTel.setEditable(false);
			break;
		}
		case SEARCH: {
			txtName.setEditable(true);
			txtEmail.setEditable(false);
			txtTel.setEditable(false);
			break;
		}
		default:
			break;
		}
		setButton(command);
	}

	// 액션 리스너
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO 자동 생성된 메소드 스텁

		Object obj = e.getSource();
		if (obj == btnTotal) {
			System.out.println("전체보기를 눌렀습니다.");
			setTitle("전체보기");
			totel();

		} else if (obj == btnAdd) {
			System.out.println("추가를 눌렀습니다.");
			if (cmd != ADD) {
				setText(ADD);
				return;
			}
			setTitle("데이터 추가");
			add();

		} else if (obj == btnCancel) {
			System.out.println("닫기를 눌렀습니다.");

		} else if (obj == btnSearch) {
			System.out.println("찾기를 눌렀습니다.");
			search();

		} else if (obj == btnDel) {
			System.out.println("삭제를 눌렀습니다.");
			if (cmd != DELETE) {
				setText(DELETE);
				return;
			}
			setTitle("데이터 삭제");
			delete();

		}
		setText(NONE);

	}

	private void search() {
		// TODO 자동 생성된 메소드 스텁
		try {

			// txtname에 이름이 없으면 메시지 박스를 출력하고 return
			String Strname = txtName.getText();
			if (Strname.trim().length() < 1) {
				JOptionPane.showMessageDialog(null, "이름 적어");
				return;
			}

			pstmtSearch = con.prepareStatement(sqlSearch);
			pstmtSearch.setString(1, Strname);

			String[] columnNames = { "번호", "이름", "이메일", "전화번호", "가입일" };

			// select 구문실행
			ResultSet rs = pstmtSearch.executeQuery();

			ArrayList> data_arr = new ArrayList>();

			if (rs.next()) {
				do {
					ArrayList imsi = new ArrayList();
					imsi.add(rs.getString("CUSTOMER_ID"));
					imsi.add(rs.getString("NAME"));
					imsi.add(rs.getString("EMAIL"));
					imsi.add(rs.getString("TAL"));
					imsi.add(rs.getString("JOIDATE"));
					data_arr.add(imsi);
				} while (rs.next());

				String[][] data = new String[data_arr.size()][5];

				for (int i = 0; i < data_arr.size(); i++) {
					ArrayList al = data_arr.get(i);
					for (int j = 0; j < 5; j++) {
						data[i][j] = al.get(j);
					}
				}

				// 테이블에 출력하기 위한 데이터 모델 생성
				DefaultTableModel model = new DefaultTableModel(data,
						columnNames);

				// 테이블 모델 적용
				table.setModel(model);
				// 테이블 갱신
				table.updateUI();
			} else {
				JOptionPane.showMessageDialog(null, "데이터 없음");
			}

			rs.close();

		} catch (Exception e) {
			JOptionPane.showMessageDialog(null, e.getMessage());
		} finally {

			try {
				if (pstmtSearch != null)
					pstmtSearch.close();
			} catch (SQLException e) {
				// TODO 자동 생성된 catch 블록
				e.printStackTrace();
			}

		}

	}

	// 모든 데이터를 보여주는 정의 메서드
	private void totel() {
		try {
			pstmtTotal = con.prepareStatement(sqlTotal);

			// select 구문 실행
			ResultSet rs = pstmtTotal.executeQuery();

			String[] columnNames = { "번호", "이름", "이메일", "전화번호", "가입일" };
			ArrayList> imsiData = new ArrayList>();

			if (rs.next()) {

				do {
					// 하나의 행 데이터를 저장할 가변 배열 생성
					ArrayList imsi = new ArrayList();
					imsi.add(rs.getString("CUSTOMER_ID"));
					imsi.add(rs.getString("NAME"));
					imsi.add(rs.getString("EMAIL"));
					imsi.add(rs.getString("TAL"));
					imsi.add(rs.getString("JOIDATE"));

					imsiData.add(imsi);

				} while (rs.next());

				// 테이블에 데이터를 출력하기 위해서
				// 테이버베이스에서 읽어온 데이터를 2차원 배열로 반환
				String[][] data = new String[imsiData.size()][5];
				for (int i = 0; i < imsiData.size(); i++) {
					ArrayList al = imsiData.get(i);
					for (int j = 0; j < 5; j++) {
						data[i][j] = al.get(j);
					}

				}

				// 테이블에 출력하기 위한 데이터 모델 생성
				DefaultTableModel model = new DefaultTableModel(data,
						columnNames);

				// 테이블 모델 적용
				table.setModel(model);
				// 테이블 갱신
				table.updateUI();
			} else {
				JOptionPane.showMessageDialog(null, "데이터가 없다");
			}

		} catch (Exception e) {
			JOptionPane.showMessageDialog(null, e.getMessage());
		} finally {
			try {
				if (pstmtTotal != null)
					pstmtTotal.close();
			} catch (Exception e) {

			}
		}

	}

	// 데이터를 삭제하는 사용자 정의 메서드
	private void delete() {
		try {
			String strname = txtName.getText();
			if (strname.trim().length() < 1) {
				JOptionPane.showMessageDialog(null, "이름 필수 입력");
				return;
			}

			pstmtDelete = con.prepareStatement(sqlDelete);
			pstmtDelete.setString(1, strname);

			int result = pstmtDelete.executeUpdate();
			if (result > 0) {
				JOptionPane.showMessageDialog(null, "삭제 성공");
			} else {
				JOptionPane.showMessageDialog(null, "삭제할 이름 없음");
			}

		} catch (Exception e) {
			JOptionPane.showMessageDialog(null, e.getMessage());
		} finally {
			try {
				if (pstmtDelete != null)
					pstmtDelete.close();
			} catch (Exception e) {

			}

		}
	}

	// 데이터를 추가하는 사용자 정의 메서드
	private void add() {
		try {
			// 유호성 검사 - txtname에 텍스트 확인
			String strname = txtName.getText();
			String strEmail = txtEmail.getText();
			String strTel = txtTel.getText();

			if (strname.trim().length() < 1) {
				JOptionPane.showMessageDialog(null, "이름 필수 입력");
				return;
			}
			// 삽입하는 sql 문장을 수행해 줄 Statement 생성
			pstmtInsert = con.prepareStatement(sqlInsert);
			pstmtInsert.setString(1, strname);
			pstmtInsert.setString(2, strEmail);
			pstmtInsert.setString(3, strTel);

			int result = pstmtInsert.executeUpdate();
			if (result > 0) {
				JOptionPane.showMessageDialog(null, "삽입 성공");
			} else {
				JOptionPane.showMessageDialog(null, "삽입 실패");
			}

		} catch (Exception e) {
			JOptionPane.showMessageDialog(null, e.getMessage());
		} finally {
			try {
				if (pstmtInsert != null)
					pstmtInsert.close();
			} catch (Exception e) {

			}
		}
	}

}


Customer.java


package CustomerDB;

//customer 테이블의 데이터를 표현할 클래스
public class Customer {
	//변수명은 특별한 경우가 아니면 테이블의 컬럼 이름을 그래도 사용
	private String customer_id;
	private String name;
	private String email;
	private String tel;
	private String joidate;
	public Customer() {
		super();
		// TODO 자동 생성된 생성자 스텁
	}
	public Customer(String customer_id, String name, String email, String tel,
			String joidate) {
		super();
		this.customer_id = customer_id;
		this.name = name;
		this.email = email;
		this.tel = tel;
		this.joidate = joidate;
	}
	
	
	public String getCustomer_id() {
		return customer_id;
	}
	public void setCustomer_id(String customer_id) {
		this.customer_id = customer_id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getTel() {
		return tel;
	}
	public void setTel(String tel) {
		this.tel = tel;
	}
	public String getJoidate() {
		return joidate;
	}
	public void setJoidate(String joidate) {
		this.joidate = joidate;
	}
	@Override
	public String toString() {
		return "Customer [customer_id=" + customer_id + ", name=" + name
				+ ", email=" + email + ", tel=" + tel + ", joidate=" + joidate
				+ "]";
	}
	
	//디버깅을 위한 메서드
	
}


Main.java


package CustomerDB;

public class Main {

	public static void main(String[] args) {
		// TODO 자동 생성된 메소드 스텁
		
		//new CustomerDBUse();
		//new CopyOfCustomerDBUse_1();
		
		new CopyOfCustomerDBUse_hachmap();
	}

}


'JAVA > Java' 카테고리의 다른 글

java String Calss  (0) 2015.03.18
[JAVA] SocketServer  (0) 2014.11.18
[JAVA] Mysql DB 접속하기(Connect)  (0) 2014.11.18
[JAVA] Oracle DB 접속 후 Insert,select 하기  (0) 2014.11.18
[JAVA] oracle DB 접속하기  (0) 2014.11.18
반응형
<


package mysql_DB;

import java.sql.*;

public class MySQLconnect {

	public static void main(String[] args) {
		// TODO 자동 생성된 메소드 스텁

		try {
			Class.forName("com.mysql.jdbc.Driver");
			System.out.println("클래스 로드 성공");

			Connection con = DriverManager.getConnection(
					"jdbc:mysql://127.0.0.1:3306/db", "id", "password");
			System.out.println("접속 성공");

			con.close();
		} catch (Exception e) {
			System.out.println(e.getMessage());
		} finally {
			
		}

	}

}


반응형



import java.sql.*;


public class OracleDB {

	public static void main(String[] args) {
		// 1. 데이터베이스 연동 클래스 로드
		try{
			Class.forName("oracle.jdbc.driver.OracleDriver");
		}
		catch(Exception e){
			System.out.println(e.getMessage());
			//프로그램 정상 종료
			System.exit(0);
		}
		
		//2. 데이터베이스에 접속해서 test1 테이블의 데이터 읽기
		
		//데이터베이스에 접속하기 위한 변수
		Connection con = null;
		//SQL 구문을 실행하기 위한 변수
		Statement stmt = null;
		//Select 구문 실행했을 때 결과를 저장하기 위한 변수
		ResultSet rs = null;
		
		//삽입을 위한 Statement 변수 선언
		PreparedStatement pstmt = null;
		try{
			con = DriverManager.getConnection(
					"jdbc:oracle:thin:@127.0.0.1:1521:orcl",
					"id","password");
			
			//sql 문장을 가지고 PreparedStatement 객체 생성
			pstmt = con.prepareStatement(
					"insert into test1 values(id_sequence.nextval, ?)");
			//?에 데이터를 바인딩
			pstmt.setString(1, "이순신");
			//실행
			int result = pstmt.executeUpdate();
			System.out.println("영향 받은 행의 개수:" + result);
			
			//sql 구문을 실행할 수 있는 객체 생성
			stmt = con.createStatement();
			//select 구문을 실행
			rs = stmt.executeQuery("select * from test1");
			//데이터가 있을 때
			if(rs.next()){
				do{
					System.out.println(rs.getInt(1) + ":" +
							rs.getString(2));
				}while(rs.next());
			}
			else{
				System.out.println("읽은 데이터가 없습니다.");
			}
			
		}
		catch(Exception e){
			System.out.println(e.getMessage());
		}
		finally{
			try{
				if(rs != null)rs.close();
				if(stmt != null)stmt.close();
				if(con != null)con.close();
			}
			catch(Exception e){}
		}

	}

}


반응형



import java.sql.*;
import java.util.*;

public class RunProc {

	public static void main(String arg[]) {
		
		Common.loadDrover();
		Connection con = null;

		CallableStatement cstmt = null;

		try {
			con = DriverManager.getConnection(
					"jdbc::oracle:thin:@127.0.0.1:1521:orcl", "사용자아이디",
					"사용자 패스워드");
			System.out.print("저장할 메시지: ");
			Scanner sc = new Scanner(System.in);
			String msg = sc.nextLine();
			sc.close();

			cstmt = con.prepareCall("{call myproc(?)}");
			cstmt.setString(1, msg);
			cstmt.executeQuery();
		} catch (Exception e) {
			System.out.println(e.getMessage());
		} finally {
			try {
				if (cstmt != null)
					cstmt.close();
				if (con != null)
					con.close();

			}

			catch (Exception e) {
			}
		}

	}

}



반응형

DomThread.java


package xml_pasing;

import java.io.*;
import java.net.*;
import java.util.*;

import javax.xml.parsers.*;

import org.w3c.dom.*;

public class DomThread extends Thread {
	// 다운로드 받은 문자열을 저장할 변수
	String xml;
	// 파싱한 결과를 저정할 ArrayList
	
	
	//첫번째 방법
	ArrayList data = new ArrayList();
	//두번째 방법
	ArrayList> data_1 = new ArrayList>();

	// 스레드로 동작할 메서드
	public void run() {
		// 다운로드 받는 도중 데이터를 저장할 변수
		StringBuilder sBuffer = new StringBuilder();
		// 다운로드 처리
		try {
			// 다운로드 받을 변수
			String urlAddr = "http://www.kma.go.kr/weather/forecast/mid-term-xml.jsp?stnId=109";
			URL url = new URL(urlAddr);
			HttpURLConnection conn = (HttpURLConnection) url.openConnection();
			if (conn != null) {
				// 연결에 대한 설정
				conn.setConnectTimeout(10000);
				conn.setUseCaches(false);
				// 정상적으로 연결에 성명하면
				if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
					// 줄 단위로 읽어오기 위한 BufferedReader 객체 생성
					InputStreamReader isr = new InputStreamReader(
							conn.getInputStream());
					BufferedReader br = new BufferedReader(isr);
					while (true) {
						String line = br.readLine();
						if (line == null)
							break;
						sBuffer.append(line);
					}
					br.close();
					conn.disconnect();
					xml = sBuffer.toString();
				}
			}
		} catch (Exception e) {
			System.out.println(e.getMessage());

		}
		// xml이 가진 문자열을 파싱
		try {
			if (xml != null) {
				// xml을 파싱해주는 객체를 생성
				DocumentBuilderFactory factory = DocumentBuilderFactory
						.newInstance();
				DocumentBuilder documentBuilder = factory.newDocumentBuilder();

				// xml 문자열은 InputStream으로 변환
				InputStream is = new ByteArrayInputStream(xml.getBytes());
				// 파싱 시작
				Document doc = documentBuilder.parse(is);
				// 최상위 노드 찾기
				Element element = doc.getDocumentElement();
				// 원하는 태그 데이터 찾아오기
				NodeList items = element.getElementsByTagName("tmx");
				NodeList items1 = element.getElementsByTagName("tmn");
				NodeList items2 = element.getElementsByTagName("reliability");
				// 데이터 개수 찾이오기
				int n = items.getLength();
				for (int i = 0; i < n; i++) {

					HashMap map = new HashMap();

					Node item = items.item(i);
					Node text = item.getFirstChild();
					String itemValue = text.getNodeValue();
					map.put("최고온도", itemValue);

					Node item1 = items1.item(i);
					Node text1 = item1.getFirstChild();
					String itemValue1 = text1.getNodeValue();
					map.put("최저온도", itemValue1);

					Node item2 = items2.item(i);
					Node text2 = item2.getFirstChild();
					String itemValue2 = text2.getNodeValue();
					map.put("신뢰도", itemValue2);
					// 찾은 데이터 datadp 추가
					data_1.add(map);
					data.add(new Data_tansfer(itemValue,itemValue1,itemValue2));

				}
			}

		} catch (Exception e) {
			System.out.println(e.getMessage());

		}

		System.out.println(data);
		System.out.println(data_1);
	}
}


Data_tansfer.java


package xml_pasing;

import java.io.*;

public class Data_tansfer implements Serializable{
	
	private String tmx;
	private String tmn;
	private String reliability;
	
	public Data_tansfer() {
		super();
		// TODO 자동 생성된 생성자 스텁
	}

	public String getTmx() {
		return tmx;
	}

	public void setTmx(String tmx) {
		this.tmx = tmx;
	}

	public String getTmn() {
		return tmn;
	}

	public void setTmn(String tmn) {
		this.tmn = tmn;
	}

	public String getReliability() {
		return reliability;
	}

	public void setReliability(String reliability) {
		this.reliability = reliability;
	}

	@Override
	public String toString() {
		return "Data_tansfer [tmx=" + tmx + ", tmn=" + tmn + ", reliability="
				+ reliability + "]";
	}

	public Data_tansfer(String tmx, String tmn, String reliability) {
		this.tmx = tmx;
		this.tmn = tmn;
		this.reliability = reliability;
	}




	

}


Dom_main.java


package xml_pasing;

public class Dom_main {

	public static void main(String[] args) {
		// TODO 자동 생성된 메소드 스텁
		
		DomThread th =  new DomThread();
		th.start();

	}

}


+ Recent posts