code and make bat
cls
@ECHO OFF
title Folder private
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Private goto MDLOCKER
:CONFIRM
echo Are you sure you want to lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Private "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to unlock folder
set/p "pass=>"
if NOT %pass%==1234 goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Private
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Private
echo Private created successfully
goto End
Here you will find lots of code [JAVA & JAVASCRIPT] & some links that are useful for web development and stand alone projects in java. If you need more contact me on my email.
5/30/09
5/29/09
5/23/09
4 - Hand Tree
public void get_trees(String id)
{
try{
java.sql.Connection con=new model.connection.connection().getCon();
java.sql.Statement st=con.createStatement();
java.sql.ResultSet rs=st.executeQuery("select child_1,child_2,child_3,child_4 from "+tablename+" where emp_code='"+id.trim()+"'");
if(rs.next())
{
String c1=rs.getString(1).trim();
String c2=rs.getString(2).trim();
String c3=rs.getString(3).trim();
String c4=rs.getString(4).trim();
if(c1.equals("N"))
{
v.addElement("N");
}
else
{
v.addElement(c1);
}
if(c2.equals("N"))
{
v.addElement("N");
}
else
{
v.addElement(c2);
}
if(c3.equals("N"))
{
v.addElement("N");
}
else
{
v.addElement(c3);
}
if(c4.equals("N"))
{
v.addElement("N");
}
else
{
v.addElement(c4);
}
}
else
{
v.addElement("N");
v.addElement("N");
v.addElement("N");
v.addElement("N");
}
}
catch(Exception ex){JOptionPane.showMessageDialog(null,ex.toString());}
}
public Vector get_tree(String id)
{
try
{
int x=0;
get_trees(id) ;
for(int y=0;y<2;y++)
{
int size= v.size();
System.out.println("S"+size);
for(;x {
//String sp[]=v.get(x).toString().split("
");
get_trees(v.get(x).toString());
// System.out.println(sp[1]);
}
//System.out.println(tot+""+tot.size());
//System.out.println(");
}
}
catch(Exception e1)
{
System.out.print(e1+"get");
}
return v;
}
{
try{
java.sql.Connection con=new model.connection.connection().getCon();
java.sql.Statement st=con.createStatement();
java.sql.ResultSet rs=st.executeQuery("select child_1,child_2,child_3,child_4 from "+tablename+" where emp_code='"+id.trim()+"'");
if(rs.next())
{
String c1=rs.getString(1).trim();
String c2=rs.getString(2).trim();
String c3=rs.getString(3).trim();
String c4=rs.getString(4).trim();
if(c1.equals("N"))
{
v.addElement("N");
}
else
{
v.addElement(c1);
}
if(c2.equals("N"))
{
v.addElement("N");
}
else
{
v.addElement(c2);
}
if(c3.equals("N"))
{
v.addElement("N");
}
else
{
v.addElement(c3);
}
if(c4.equals("N"))
{
v.addElement("N");
}
else
{
v.addElement(c4);
}
}
else
{
v.addElement("N");
v.addElement("N");
v.addElement("N");
v.addElement("N");
}
}
catch(Exception ex){JOptionPane.showMessageDialog(null,ex.toString());}
}
public Vector get_tree(String id)
{
try
{
int x=0;
get_trees(id) ;
for(int y=0;y<2;y++)
{
int size= v.size();
System.out.println("S"+size);
for(;x
//String sp[]=v.get(x).toString().split("
");
get_trees(v.get(x).toString());
// System.out.println(sp[1]);
}
//System.out.println(tot+""+tot.size());
//System.out.println(");
}
}
catch(Exception e1)
{
System.out.print(e1+"get");
}
return v;
}
5/11/09
To Set window in the middle of screen
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JFrame;
public class Main {
public static void main(String[] argv) throws Exception {
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
JFrame window = new JFrame();
window.setSize(300,300);
int w = window.getSize().width;
int h = window.getSize().height;
int x = (dim.width - w) / 2;
int y = (dim.height - h) / 2;
window.setLocation(x, y);
window.setVisible(true);
}
}
import java.awt.Toolkit;
import javax.swing.JFrame;
public class Main {
public static void main(String[] argv) throws Exception {
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
JFrame window = new JFrame();
window.setSize(300,300);
int w = window.getSize().width;
int h = window.getSize().height;
int x = (dim.width - w) / 2;
int y = (dim.height - h) / 2;
window.setLocation(x, y);
window.setVisible(true);
}
}
5/9/09
Marging 2 PDF Hello1 and Hello2 using Itext.jar
PdfReader reader = new PdfReader("Hello1.pdf");
Document document = new Document(reader.getPageSizeWithRotation(1));
PdfCopy copy = new PdfCopy(document,new FileOutputStream("HelloWorldPdfCopy123.pdf"));
document.open();
System.out.println("Tampered? " + reader.isTampered());
copy.addPage(copy.getImportedPage(reader, 1));
reader = new PdfReader("Hello2.pdf");
copy.addPage(copy.getImportedPage(reader, 1));
System.out.println("Tampered? " + reader.isTampered());
document.close();
Document document = new Document(reader.getPageSizeWithRotation(1));
PdfCopy copy = new PdfCopy(document,new FileOutputStream("HelloWorldPdfCopy123.pdf"));
document.open();
System.out.println("Tampered? " + reader.isTampered());
copy.addPage(copy.getImportedPage(reader, 1));
reader = new PdfReader("Hello2.pdf");
copy.addPage(copy.getImportedPage(reader, 1));
System.out.println("Tampered? " + reader.isTampered());
document.close();
5/2/09
To Make a PDF using Images [ iText.jar ]
Document d=new Document();
PdfWriter.getInstance(d, new FileOutputStream("op.pdf"));
d.open();
Image img1 = Image.getInstance("hellsing.jpg");
d.add(img1);
d.close();
PdfWriter.getInstance(d, new FileOutputStream("op.pdf"));
d.open();
Image img1 = Image.getInstance("hellsing.jpg");
d.add(img1);
d.close();
To start a process with ProcessBuilder
try {ProcessBuilder proc = new ProcessBuilder("notepad.exe", "testfile");
proc.start();
} catch (Exception e) {
System.out.println("Error executing notepad.");
}
To open a file in it's editor [Default]
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] a) {
try {
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
desktop.edit(new File("hellsing.jpg"));
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] a) {
try {
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
desktop.edit(new File("hellsing.jpg"));
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
Code for Browsing a Site when uninstalling of installing Application
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
public class Main {
public static void main(String[] a) {
try {
URI uri = new URI("http://www.java2s.com");
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
if (desktop != null)
desktop.browse(uri);
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (URISyntaxException use) {
use.printStackTrace();
}
}
}
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
public class Main {
public static void main(String[] a) {
try {
URI uri = new URI("http://www.java2s.com");
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
if (desktop != null)
desktop.browse(uri);
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (URISyntaxException use) {
use.printStackTrace();
}
}
}
Subscribe to:
Posts (Atom)