⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chaincommand.java

📁 是内存受限系统设计的代码。
💻 JAVA
字号:
import java.util.*;
import java.io.*;

class ChainCommand
{
    public static void assert (boolean  assertion, String excuse) {
        if  (!assertion) { throw new RuntimeException(excuse);}
    }

    public static void progress (String msg) {System.out.print(msg);}

    public static void main( String[] args )  {
        progress(".");
        try {
            String s = ExecuteACommand( "command.com /c dir"  );
            System.out.println( "Command DIR returned: " + s );
            //          ChainToCommand( "c:\\windows\\notepad.exe" );
        } catch ( IOException e ) {
            assert( false, "IOException thrown " + e );
        }
        System.out.println("done!");
    }

    static String ExecuteACommand( String theCommand ) throws IOException {
        Process p = Runtime.getRuntime().exec(theCommand);
        InputStream processOutput = p.getInputStream();
        String result = new String();
        byte buf[] = new byte[20];
        int i;
        while ((i = processOutput.read(buf)) >= 0)
            result = result + new String( buf, 0, 0, i );
        return result;
    }

    static void ChainToCommand( String theCommand ) throws IOException  {
        Runtime.getRuntime().exec(theCommand);
        Runtime.getRuntime().exit( 0 );
    }
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -