This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File input = new File("/file/to/path"); | |
File destination = new File("/file/to"); | |
Archiver archiver = ArchiverFactory.createArchiver(ArchiveFormat.ZIP); | |
((Archiver) archiver).extract(input,destination); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* unzip file | |
String zipFile = "/file/to/path"; | |
File destinationDir = new File("/file/to/); | |
java.util.zip.ZipFile zipFile = new ZipFilezipFile | |
try{ | |
Enumeration<? extends ZipEntry> entries = zipFile.entries(); | |
while (entries.hasMoreElements()){ | |
ZipEntry entry = entries.nextElement(); | |
File entryDestination = new File(destinationDir); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void zipDirectory(File dir, String zipDirName){ | |
try{ | |
populateFilesList(dir); | |
FileOutputStream fos = new FileOutputStream(zipDirName); | |
ZipOutputStream zos = new ZipOutputStream(fos); | |
for(String filePath : filesListInDir){ | |
System.out.println("zipping " + filePath); | |
ZipEntry ze = new ZipEntry(filePath.substring(dir.getAbsolutePath().length() + 1, filePath.length())); | |
zos.putNextEntry(ze); | |
FileInputStream fis = new FileInputStream(filePath); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void tarDirectory(File dir, TarOutputStream zos, String lPath) { | |
try { | |
for (File filePath : dir.listFiles()) { | |
System.out.println("Tarring " + filePath); | |
TarEntry entry = new TarEntry(filePath,filePath.getAbsolutePath().substring(lPath.length())); | |
zos.putNextEntry(entry); | |
if(filePath.isDirectory()){ | |
tarDirectory(filePath,zos,lPath); | |
} | |
else if (filePath.isFile()){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Digital sign | |
public static void Signature(String zipDirName, String lPath) throws NoSuchAlgorithmException, InvalidKeyException, IOException, SignatureException, NoSuchProviderException, InvalidKeySpecException { | |
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DSA","SUN"); | |
keyPairGenerator.initialize(1024); | |
KeyPair keyPair = keyPairGenerator.generateKeyPair(); | |
PrivateKey privateKey = keyPair.getPrivate(); | |
PublicKey publicKey = keyPair.getPublic(); | |
Signature dsa = Signature.getInstance("SHA1withDSA", "SUN"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Encrypto() throws IOException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, NoSuchProviderException { | |
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); | |
keyPairGenerator.initialize(1024); | |
KeyPair keyPair = keyPairGenerator.generateKeyPair(); | |
PrivateKey privateKey = keyPair.getPrivate(); | |
try (FileInputStream fis = new FileInputStream("File.txt"); | |
FileOutputStream fos = new FileOutputStream("FileEncrypt.txt")) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Encrypt() throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, IOException { | |
try (FileInputStream fis = new FileInputStream("File.zip"); | |
FileOutputStream fos = new FileOutputStream("EncryptFile.zip")) { | |
byte k[] = "NiTh5252".getBytes(); | |
SecretKeySpec key = new SecretKeySpec(k, "DES"); | |
Cipher enc = Cipher.getInstance("DES"); | |
enc.init(Cipher.ENCRYPT_MODE, key); | |
CipherOutputStream cos = new CipherOutputStream(fos, enc); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Banka() | |
{ | |
string sql = @"SELECT [Hesap kodu] | |
,[Hesap Adı] | |
FROM ..."; | |
using (SqlConnection con = new SqlConnection(SessionHelper.ConnectionString)) | |
{ | |
if (con.State != System.Data.ConnectionState.Open) | |
con.Open(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void BankAccount_() | |
{ | |
string sql = @"SELECT [Hesap kodu] | |
,[Hesap Adı] | |
FROM ..."; | |
using (SqlConnection con = new SqlConnection(SessionHelper.ConnectionString)) | |
{ | |
if (con.State != System.Data.ConnectionState.Open) | |
con.Open(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Action(Caption = "Add Company")] | |
public void Company_Transfer() | |
{ | |
StaticDefinitions sdMuhasebeKodu = Session.FindObject<StaticDefinitions>(CriteriaOperator.Parse("Key == 'Acc_Company_Account'")); | |
if (sdMuhasebeKodu == null) | |
throw new UserFriendlyException("Muhasebe kodu static tanım bulunamadı"); | |
string sql = @"SELECT [Hesap kodu] | |
,[Hesap Adı] | |
FROM ...]"; |
NewerOlder