Run cmd command from java

import java.io.*;

import java.util.*;

public class CmdVerJavaDemo{

BufferedReader x=new BufferedReader(new InputStreamReader(System.in));

Runtime myrun;

Process output;

public static void main(String args[])throws IOException

{

(new CmdVerJavaDemo()).runCmdCommand("dir *.*");

}

public void runCmdCommand(String cmd)throws IOException

{

System.out.println("Your Cmd Command is "+cmd);

myrun=Runtime.getRuntime();

output=myrun.exec("cmd /c "+cmd);

String outStr="";

String fDate="";

String fName="";

x=new BufferedReader(new
InputStreamReader(output.getInputStream()));

for(int i=0;i<=100 && outStr!=null;i++)

{

outStr=x.readLine();

if(outStr==null)

{

System.out.println("File Data has null
.");

}

else

{

System.out.println(outStr);

StringTokenizer strToken=new
StringTokenizer(outStr);

int countT=strToken.countTokens();

if(i>=6)

{


fDate=strToken.nextToken();


fName=strToken.nextToken();


fName=strToken.nextToken();


fName=strToken.nextToken();


fName=strToken.nextToken();


fDate=fDate.replaceAll("/","-");


System.out.println("File Name :"+fName);


System.out.println("File Date :"+fDate);


output=myrun.exec("cmd /c md backup");


output=myrun.exec("cmd /c copy .\\*.* .\\backup");


output=myrun.exec("cmd /c md "+fDate);

File
fileName=new File(fName);


if((fileName.isDirectory()))


System.out.println("File Name :"+fName+" is Directory");

else


{


System.out.println("File Name :"+fName+" is File");


output=myrun.exec("cmd /c copy .\\"+fName+" .\\"+fDate);


}

}

}

}

}

}

Subscribe Sharingbywasim by sms free

If you want to get update of Sharing by Wasim Akhtar by Free sms then send from your mobile ON Sharingbywasim to +919870807070

--  Wasim Akhtar

Want to google search by your google talk

Want to google search by your google talk then  Send a chat invitation to guru@googlelabs.com.

Google Talk Guru is an experimental service that allows people to get information like sports results, weather forecasts, definitions etc via chat. It works on many popular chat applications that support Google Talk.

To start using Google Talk Guru:

1. Sign into a chat client that supports Google Talk 
2. Send a chat invitation to guru@googlelabs.com or click the "Invite myself to chat with Guru" link below. 
3. Find guru in your contact list and send chat queries to guru using the examples below:

Sport scores: score arsenal
Weather: weather Nairobi
Calculate: 123 * 45
Currency: 120 KES to USD
Definition: define laptop
Translation: translate earth to French
Web result: web Mount Kenya
Help: help translate

--  Wasim Akhtar

Make a own folder locker by command prompt

Make a own folder locker by command prompt
just copy the code and save it in any .bat file
find "if NOT %pass%== wasim" and change wasim to any thing you like to
password.
save it and run it create a folder private again run it it prompt to
lock or not folder press y your private folder is locked and hidden
to unlock again run it enter your password yours Private folder keep
your private things in private folder .

------------------------------------From
Here----------------------------------
@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%== wasim 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
:End
------------------------------------End
Here----------------------------------

--
Wasim Akhtar

Invitation to connect on LinkedIn

LinkedIn

I'd like to add you to my professional network on LinkedIn.

- Wasim

Wasim Akhtar
Student at Indira Gandhi National Open University
Bettiah Area, India

Confirm that you know Wasim

© 2011, LinkedIn Corporation

Want To Download Torrent File By Using Google

Simple way...just type:

*ur file name* filetype:torrent
You must not write ( * ) when you search....
Eksample:
ANTIVIRUS KASPERSKY filetype:torrent

--
Wasim Akhtar

Avast! Free Antivirus 6.0.1203

avast! Free Antivirus represents the best free antivirus protection currently available on the market. This edition is FREE OF CHARGE for non-commercial & home use. Its features include:

  • Anti-spyware built-in
  • Web Shield
  • Anti-rootkit built-in
  • Automatic updates
  • Strong self-protection
  • Virus Chest
  • Antivirus kernel
  • System integration
  • Simple User Interface
  • Integrated Virus Cleaner
  • Resident protection
  • Support for 64-bit Windows
  • P2P and IM Shields
  • Internationalization
  • Network Shield
Download Here
--  Wasim Akhtar

Windows 11 Dev Insider Preview Build 26120.461 Released, Here is What’s New and Fixed

UPDATE: Windows 11 Insider Preview build 26120.461 (KB5037009) released to Dev channel. Windows Insiders in the Dev Channel will now receive...