Example usage for java.lang System exit

List of usage examples for java.lang System exit

Introduction

In this page you can find the example usage for java.lang System exit.

Prototype

public static void exit(int status) 

Source Link

Document

Terminates the currently running Java Virtual Machine.

Usage

From source file:MappedReader.java

public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        System.out.println("argument: sourcefile");
        System.exit(1);
    }//from w  ww  .j a v a  2s.c  o  m
    MappedByteBuffer in = new FileInputStream(args[0]).getChannel().map(FileChannel.MapMode.READ_ONLY, 0,
            LENGTH);
    int i = 0;
    while (i < LENGTH)
        System.out.print((char) in.get(i++));
    System.out.println((char) in.get(i++));
}

From source file:MainClass.java

public static void main(String[] a) {
    File aFile = new File("C:/myFile.text");
    FileOutputStream outputFile = null; // Place to store an output stream
                                        // reference
    try {/*from  ww  w.  j  a v  a2  s  . co m*/
        // Create the stream opened to write
        outputFile = new FileOutputStream(aFile);
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
        System.exit(1);
    }
    // Get the channel for the file
    FileChannel outputChannel = outputFile.getChannel();
}

From source file:JavaWorldPrintExample1.java

public static void main(String[] args) {

    JavaWorldPrintExample1 example1 = new JavaWorldPrintExample1();
    System.exit(0);
}

From source file:AddException.java

/** Main program */
public static void main(String[] argv) {
    int number = 0;

    System.out.println("The number of words in argv is " + argv.length);

    if (argv.length == 0) {
        number = 1234;//from ww w.  j a  v a2s. c  o m
    } else if (argv.length == 1) {
        try {
            number = Integer.parseInt(argv[0]);
        } catch (NumberFormatException e) {
            System.err.println("Number " + argv[0] + " invalid (" + e.getMessage() + ").");
            System.exit(1);
        }
    } else {
        System.err.println("usage: UseArgv number");
        System.exit(1);
    }

    System.out.println("OK, number is " + number);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setUndecorated(true);// w  ww .j a v a 2  s. c  o  m
    JPanel panel = new JPanel();
    panel.add(new JLabel("Stackoverflow!"));
    panel.add(new JButton(new AbstractAction("Close") {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    }));
    f.add(panel);
    f.pack();
    f.setVisible(true);
}

From source file:uk.ac.ebi.ep.parser.main.DiseaseFileParser.java

public static void main(String... args) throws Exception {

    if (args == null || args.length == 0) {
        System.out.println("Please provide required parameters");
        System.exit(0);
    }//from   ww  w  .  j a  v  a  2s  .c o m

    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.getEnvironment().setActiveProfiles(args[0]);
    context.scan("uk.ac.ebi.ep.data.dataconfig", "uk.ac.ebi.ep.parser.config");
    context.refresh();

    DiseaseParser diseaseParser = context.getBean(DiseaseParser.class);

    diseaseParser.parse(args[1]);

}

From source file:uk.ac.ebi.ep.parser.main.ChEBIParser.java

public static void main(String... args) throws Exception {
    if (args == null || args.length == 0) {
        System.out.println("Please provide required parameters");
        System.exit(0);
    }//from w w w. j a  va 2 s .  c om

    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.getEnvironment().setActiveProfiles(args[0]);
    context.scan("uk.ac.ebi.ep.data.dataconfig", "uk.ac.ebi.ep.parser.config");
    context.refresh();

    EnzymePortalCompoundParser compoundService = context.getBean(EnzymePortalCompoundParser.class);
    compoundService.loadChEBICompounds();

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("XML 3.0 LS 3.0");
    if (impl == null) {
        System.out.println("No DOMImplementation found !");
        System.exit(0);
    }/* w  ww. j ava2 s  .  c  o m*/

    System.out.printf("DOMImplementationLS: %s\n", impl.getClass().getName());

    LSParser parser = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, "http://www.w3.org/TR/REC-xml");
    // http://www.w3.org/2001/XMLSchema
    System.out.printf("LSParser: %s\n", parser.getClass().getName());

    Document doc = parser.parseURI("");

    LSSerializer serializer = impl.createLSSerializer();
    LSOutput output = impl.createLSOutput();
    output.setEncoding("UTF-8");
    output.setByteStream(System.out);
    serializer.write(doc, output);
    System.out.println();
}

From source file:uk.ac.ebi.ep.parser.main.CofactorParser.java

public static void main(String... args) throws Exception {
    if (args == null || args.length == 0) {
        System.out.println("Please provide required parameters");
        System.exit(0);
    }/*from   w w w .  j ava  2  s.  c  om*/

    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.getEnvironment().setActiveProfiles(args[0]);
    context.scan("uk.ac.ebi.ep.data.dataconfig", "uk.ac.ebi.ep.parser.config");
    context.refresh();

    EnzymePortalCompoundParser compoundService = context.getBean(EnzymePortalCompoundParser.class);
    compoundService.loadCofactors();

}

From source file:Main.java

public static void main(String args[]) throws Exception {
    FileInputStream fis = new FileInputStream("test");
    MessageDigest md = MessageDigest.getInstance("SHA");
    DigestInputStream dis = new DigestInputStream(fis, md);
    ObjectInputStream ois = new ObjectInputStream(dis);
    Object o = ois.readObject();//from  w ww.jav  a2  s .c  o m
    if (!(o instanceof String)) {
        System.out.println("Unexpected data in file");
        System.exit(-1);
    }
    String data = (String) o;
    System.out.println("Got message " + data);
    dis.on(false);
    o = ois.readObject();
    if (!(o instanceof byte[])) {
        System.out.println("Unexpected data in file");
        System.exit(-1);
    }
    byte origDigest[] = (byte[]) o;
    System.out.println(MessageDigest.isEqual(md.digest(), origDigest));
}