📄 admintool.java
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Library License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.//// $Id: AdminTool.java,v 1.14 2000/10/28 16:55:20 daniela Exp $package org.ozoneDB.tools;import java.io.*;import java.util.*;/** * Main class for the AdminTool. This uses CommandExecute to communicate * with the server. */class AdminTool implements IODevice { CommandExecute exec; BufferedReader input; IODevice device; public AdminTool( String host, int port ) { try { exec = new CommandExecute( this ); exec.open( host, port ); input = new BufferedReader( new InputStreamReader( System.in ) ); message( "Connected to " + host + " at port " + port ); device = this; } catch (IOException e) { System.out.println( "Unable to connect the server!" ); System.exit( 0 ); } } public String[] question( String q ) { System.out.print( q ); System.out.flush(); //MEN 6/25/1999 int iChar = 0; StringBuffer line = new StringBuffer( 128 ); try { while ((iChar = System.in.read()) != '\n') { line.append( (char)iChar ); } } catch (IOException e) { System.out.println( "Error reading command: " + e ); } StringTokenizer st = new StringTokenizer( new String( line ).trim() ); String[] com = new String[st.countTokens()]; int i = 0; while (st.hasMoreTokens()) { com[i++] = st.nextToken(); } return com; } public void message( String mess ) { System.out.println( mess ); } public void asyncMessage( String mess ) { System.out.println( mess ); } public boolean request( String req ) { String[] q = question( req ); return q[0].equals( "y" ); } public void run() { String[] com; do { com = question( "ozoneAdmin > " ); } while (exec.execute( com )); message( "Bye." ); } public void close() { try { exec.close(); } catch (Exception e) { } } public static void main( String[] args ) { String hostname = "localhost"; int port = 3000; boolean help = false; System.out.println( "ozone administration tool" ); for (int i = 0; i < args.length; i++) { if (args[i].startsWith( "-host" )) { hostname = args[i].substring( 5 ); } else if (args[i].startsWith( "-port" )) { port = Integer.parseInt( args[i].substring( 5 ) ); } else if (args[i].startsWith( "-h" )) { help = true; } else { System.out.println( "unknown option:" + args[i] ); help = true; } } if (help) { System.out.println( "\nusage: ozoneAdmin [-host<host>] [-port<number>] [-h]\n" ); System.out.println( "-host<host> the host to connect to" ); System.out.println( "-port<number> the port number to connect to the Ozone DB" ); System.out.println( "-h shows this help" ); System.exit( 0 ); } AdminTool at = new AdminTool( hostname, port ); at.run(); System.exit( 0 ); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -