Snippet007FullSelection
Demonstrates how you can use a use inline editing in tables with multiple columns which requires to use SWT.FULL_SELECTION but hiding the selection from the user.
Demonstrates how you can use a use inline editing in tables with multiple columns which requires to use SWT.FULL_SELECTION but hiding the selection from the user.
JFace TreeViewer에서 item을 더블클릭했을 때, 열고 닫기
public class NodeDoubleClickListener implements IDoubleClickListener {
@Override
public void doubleClick(DoubleClickEvent event)
{
TreeViewer viewer = (TreeViewer) event.getViewer();
Object obj = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (viewer.getExpandedState(obj))
{
viewer.collapseToLevel(obj, 1);
}
else
{//하위 전체를 열기
viewer.expandToLevel(obj, AbstractTreeViewer.ALL_LEVELS);
}
}
}
TabFolder.setSelection(tabItemIndex);
TabFolder.setFocus();
출처: http://dev.eclipse.org/newslists/news.eclipse.tools/msg37643.html
String FILENAME = "test.xml";받는 쪽 (암호화 된 파일을 풀어서 스트링으로 받기)
String str2Encryption = "aaaa";
DesEncrypter encrypter = DesEncrypter.getInstance();
ByteArrayInputStream in = new ByteArrayInputStream(str4Encryption .getBytes());
encrypter.encrypt(in, new FileOutputStream(FILENAME));
in.close();
String FILENAME = "test.xml";
DesEncrypter decrypter = DesEncrypter.getInstance();
ByteArrayOutputStream out = new ByteArrayOutputStream();decrypter.decrypt(new FileInputStream(FILENAME),out);
out.close();
String result = new String(out.toByteArray());
// Singletone
public class DesEncrypter
{
private static DesEncrypter INSTANCE;
private final static String ENCRYPTION_SALT = "abcdefgh"; // must be 8 bytes
private final static String ENCRYPTION_PASSWORD = "password";
private final static String ENCRYPTION_ALGORITHM = "PBEWithMD5AndDES";
private final static int ENCRYPTION_ITERATION = 20;private Cipher ecipher;
private Cipher dcipher;
public static DesEncrypter getInstance()
{
if (INSTANCE == null)
{
INSTANCE = new DesEncrypter();
}
return INSTANCE;
}
private DesEncrypter() {
// Create an 8-byte initialization vector
PBEKeySpec pbeKeySpec;
PBEParameterSpec pbeParameterSpec;
SecretKeyFactory secretKeyFactory;
SecretKey secretKey;try {
pbeParameterSpec = new PBEParameterSpec(ENCRYPTION_SALT.getBytes(), ENCRYPTION_ITERATION);
pbeKeySpec = new PBEKeySpec(ENCRYPTION_PASSWORD.toCharArray());secretKeyFactory = SecretKeyFactory.getInstance(ENCRYPTION_ALGORITHM);
secretKey = secretKeyFactory.generateSecret(pbeKeySpec);
dcipher = Cipher.getInstance(ENCRYPTION_ALGORITHM);
ecipher = Cipher.getInstance(ENCRYPTION_ALGORITHM);
dcipher.init(Cipher.DECRYPT_MODE, secretKey, pbeParameterSpec);
ecipher.init(Cipher.ENCRYPT_MODE, secretKey, pbeParameterSpec);
} catch (java.security.InvalidAlgorithmParameterException e) {
} catch (javax.crypto.NoSuchPaddingException e) {
} catch (java.security.NoSuchAlgorithmException e) {
} catch (java.security.InvalidKeyException e) {
} catch (InvalidKeySpecException e) {
}
}// Buffer used to transport the bytes from one stream to another
byte[] buf = new byte[1024];public void encrypt(InputStream in, OutputStream out) {
try {
// Bytes written to out will be encrypted
out = new CipherOutputStream(out, ecipher);// Read in the cleartext bytes and write to out to encrypt
int numRead = 0;
while ((numRead = in.read(buf)) >= 0) {
out.write(buf, 0, numRead);
}
out.close();
} catch (java.io.IOException e) {
}
}public void decrypt(InputStream in, OutputStream out) {
try {
// Bytes read from in will be decrypted
in = new CipherInputStream(in, dcipher);// Read in the decrypted bytes and write the cleartext to out
int numRead = 0;
while ((numRead = in.read(buf)) >= 0) {
out.write(buf, 0, numRead);
}
//out.close();
} catch (java.io.IOException e) {
}
}
}
The Java Virtual Machine Specification
SDN Home > Products & Technologies > Java Technology > Java Platform,
Standard Edition (Java SE) >
http://java.sun.com/docs/books/jvms/index.html
Inside the Java Virtual Machine
http://www.artima.com/insidejvm/ed2/index.html
JVM Resource
http://www.artima.com/insidejvm/resources/index.html
hosts파일에 추가한 내용: 127.0.0.1 eclipse.stu.edu.tw이제는 업데이트가 잘 된다... :)