Package java.io

Examples of java.io.PrintWriter.format()


            }
        } catch (OncRpcException e) {
            err.format(err_call, hostname);
            exit(1);
        } catch (UnknownHostException e) {
            err.format(err_host, hostname);
            exit(1);
        } catch (IOException e) {
            err.format(err_connect, hostname);
            exit(1);
        } finally {
View Full Code Here


            exit(1);
        } catch (UnknownHostException e) {
            err.format(err_host, hostname);
            exit(1);
        } catch (IOException e) {
            err.format(err_connect, hostname);
            exit(1);
        } finally {
            if (client != null) {
                try {
                    client.close();
View Full Code Here

        Device loopback = (InitialNaming.lookup(DeviceManager.NAME)).getDevice("loopback");
        NetDeviceAPI api = loopback.getAPI(NetDeviceAPI.class);
        ProtocolAddressInfo info = api.getProtocolAddressInfo(EthernetConstants.ETH_P_IP);
        if (info == null || !info.contains(InetAddress.getByAddress(new byte[]{127, 0, 0, 1}))) {
            PrintWriter err = getError().getPrintWriter();
            err.format(err_loopback);
            exit(1);
        }

        // Now it should be safe to do the DHCP configuration.
        getOutput().getPrintWriter().format(fmt_config, dev.getId());
View Full Code Here

        if (!argDevice.isSet()) {
            // Print MAC address, MTU and IP address(es) for all network devices.
            final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
            for (Device dev : dm.getDevicesByAPI(NetDeviceAPI.class)) {
                final NetDeviceAPI api = dev.getAPI(NetDeviceAPI.class);
                out.format(fmt_devices, dev.getId(), api.getAddress(), api.getMTU(),
                           api.getProtocolAddressInfo(EthernetConstants.ETH_P_IP));
            }
        } else {
            final Device dev = argDevice.getValue();
            final NetDeviceAPI api = dev.getAPI(NetDeviceAPI.class);
View Full Code Here

            final Device dev = argDevice.getValue();
            final NetDeviceAPI api = dev.getAPI(NetDeviceAPI.class);

            if (!argIPAddress.isSet()) {
                // Print IP address(es) for device
                out.format(fmt_ip, dev.getId(), api.getProtocolAddressInfo(EthernetConstants.ETH_P_IP));
            } else {
                // Set IP address for device
                final IPv4Address ip = argIPAddress.getValue();
                final IPv4Address mask = argSubnetMask.getValue();
                final IPv4ConfigurationService cfg = InitialNaming.lookup(IPv4ConfigurationService.NAME);
View Full Code Here

                // FIXME ... this doesn't show the device's new address because the
                // IPv4 ConfigurationServiceImpl calls processor.apply with the
                // waitUntilReady parameter == false.  (The comment in the code
                // talks about avoiding deadlocks.)
                out.format(fmt_set_ip, dev.getId(), api.getProtocolAddressInfo(EthernetConstants.ETH_P_IP));
            }
        }
    }
}
View Full Code Here

        File file2 = file2Arg.getValue();

        PrintWriter err = getError().getPrintWriter();

        if (!file1.isFile()) {
            err.format(ERR_FILE_INVALID, file1);
            exit(1);
        }

        if (!file2.isFile()) {
            err.format(ERR_FILE_INVALID, file2);
View Full Code Here

            err.format(ERR_FILE_INVALID, file1);
            exit(1);
        }

        if (!file2.isFile()) {
            err.format(ERR_FILE_INVALID, file2);
            exit(1);
        }

        BufferedInputStream bis1 = null;
        BufferedInputStream bis2 = null;
View Full Code Here

                    //done
                    break;

                if (b1 == -1) {
                    PrintWriter out = getOutput().getPrintWriter();
                    out.format(MSG_EOF, file1.toString());
                    exit(1);
                    return;
                }

                if (b2 == -1) {
View Full Code Here

                    return;
                }

                if (b2 == -1) {
                    PrintWriter out = getOutput().getPrintWriter();
                    out.format(MSG_EOF, file2.toString());
                    exit(1);
                    return;
                }

                if (b1 != b2) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.