Tuesday, April 3, 2012

Executing Windows DOS commands from JAVA



This is example to execute the dos command and display the list of the file in the Specified  Drive.
package com.jsl.example;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class ExecutingwindowsCommands {
  public static void main(String[] args) {
   try {
     Process process = Runtime.getRuntime().exec("cmd /c dir D:\\");
     InputStream in = process.getInputStream();
     InputStreamReader ins=new InputStreamReader(in);
     BufferedReader br = new BufferedReader(ins);
     String data = null;
     while ((data = br.readLine()) != null) {
        System.out.println(data);
     }
   } catch (Exception e) {
    System.out.println(e);
   }
  }
}
Sample Output:






Spring Boot 3 : JWT with SecurityFilterChain, AuthorizeHttpRequests, RequestMatchers

pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0"...