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:uk.ac.ebi.ep.parser.main.IntenzXmlParser.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);
    }//  w w w.j  a  v a2 s  . co 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();
    EnzymePortalCompoundParser compoundService = context.getBean(EnzymePortalCompoundParser.class);

    compoundService.parseIntenzAndLoadCompoundsAndReactions(args[1]);

}

From source file:ChannelCopy.java

public static void main(String[] args) throws Exception {
    if (args.length != 2) {
        System.out.println("arguments: sourcefile destfile");
        System.exit(1);
    }//from w  ww .  j  a v  a  2s .c  om
    FileChannel in = new FileInputStream(args[0]).getChannel(),
            out = new FileOutputStream(args[1]).getChannel();
    ByteBuffer buffer = ByteBuffer.allocate(BSIZE);
    while (in.read(buffer) != -1) {
        buffer.flip(); // Prepare for writing
        out.write(buffer);
        buffer.clear(); // Prepare for reading
    }
}

From source file:uk.ac.ebi.ep.parser.main.ChEMBLXmlParser.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 ww .j  av a2s  .  com*/

    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.parseAndLoadChEMBLCompounds(args[1]);

}

From source file:SimpleXMLTransform.java

static public void main(String[] arg) {
    if (arg.length != 3) {
        System.err.println("Usage: SimpleXMLTransform " + "<input.xml> <input.xsl> <output>");
        System.exit(1);
    }//from w  ww.  ja v a  2  s  .  co  m
    String inXML = arg[0];
    String inXSL = arg[1];
    String outTXT = arg[2];

    SimpleXMLTransform st = new SimpleXMLTransform();
    try {
        st.transform(inXML, inXSL, outTXT);
    } catch (TransformerConfigurationException e) {
        System.err.println("Invalid factory configuration");
        System.err.println(e);
    } catch (TransformerException e) {
        System.err.println("Error during transformation");
        System.err.println(e);
    }
}

From source file:Play.java

public static void main(String args[]) {
    try {//from w w w . j av  a 2s .  c om
        // Loop
        URL url = new URL("http://java.sun.com/applets/other/Hangman/audio/whoopy.au");
        AudioClip clip = Applet.newAudioClip(url);
        clip.loop();
        Thread.sleep(5000);
        //Play
        File file = new File("bark.wav");
        clip = Applet.newAudioClip(file.toURL());
        clip.play();
        Thread.sleep(500);
        System.exit(0);
    } catch (InterruptedException e) {
    } catch (MalformedURLException e) {
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        System.err.println("usage: java TextReader " + "file location");
        System.exit(0);
    }//from  ww w.j  a  va2s.c o  m
    readFile(args[0]);
}

From source file:MainClass.java

public static void main(String[] args) {
    File aFile = new File("data.dat");
    FileInputStream inFile = null;

    try {/*from w ww .j  a v a 2 s . co m*/
        inFile = new FileInputStream(aFile);
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
        System.exit(1);
    }

    FileChannel inChannel = inFile.getChannel();
    final int COUNT = 6;
    ByteBuffer buf = ByteBuffer.allocate(8 * COUNT);
    long[] data = new long[COUNT];
    try {
        int pos = 0;
        while (inChannel.read(buf) != -1) {
            try {
                ((ByteBuffer) (buf.flip())).asLongBuffer().get(data);
                pos = data.length;
            } catch (BufferUnderflowException e) {
                LongBuffer longBuf = buf.asLongBuffer();
                pos = longBuf.remaining();
                longBuf.get(data, 0, pos);
            }
            System.out.println();
            for (int i = 0; i < pos; i++) {
                System.out.printf("%10d", data[i]);
            }
            buf.clear();
        }
        System.out.println("\nEOF reached.");
        inFile.close();
    } catch (IOException e) {
        e.printStackTrace(System.err);
        System.exit(1);
    }
}

From source file:WindowTest.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Window Listener");
    WindowListener listener = new WindowListener() {
        public void windowActivated(WindowEvent w) {
            System.out.println(w);
        }/*w  ww.j  av  a2 s .  c om*/

        public void windowClosed(WindowEvent w) {
            System.out.println(w);
        }

        public void windowClosing(WindowEvent w) {
            System.out.println(w);
            System.exit(0);
        }

        public void windowDeactivated(WindowEvent w) {
            System.out.println(w);
        }

        public void windowDeiconified(WindowEvent w) {
            System.out.println(w);
        }

        public void windowIconified(WindowEvent w) {
            System.out.println(w);
        }

        public void windowOpened(WindowEvent w) {
            System.out.println(w);
        }
    };
    frame.addWindowListener(listener);
    frame.setSize(300, 300);
    frame.show();
}

From source file:Diff.java

public static void main(String args[]) {
    RandomAccessFile fh1 = null;//from   w w w.  j  a  va 2s .co  m
    RandomAccessFile fh2 = null;
    int bufsize; // size of smallest file
    long filesize1 = -1;
    long filesize2 = -1;
    byte buffer1[]; // the two file caches
    byte buffer2[];
    // check what you get as command-line arguments
    if (args.length == 0 || args[0].equals("?")) {
        System.err.println("USAGE: java Diff <file1> <file2> | ?");
        System.exit(0);
    }
    // open file ONE for reading
    try {
        fh1 = new RandomAccessFile(args[0], "r");
        filesize1 = fh1.length();
    } catch (IOException ioErr) {
        System.err.println("Could not find " + args[0]);
        System.err.println(ioErr);
        System.exit(100);
    }
    // open file TWO for reading
    try {
        fh2 = new RandomAccessFile(args[1], "r");
        filesize2 = fh2.length();
    } catch (IOException ioErr) {
        System.err.println("Could not find " + args[1]);
        System.err.println(ioErr);
        System.exit(100);
    }
    if (filesize1 != filesize2) {
        System.out.println("Files differ in size !");
        System.out.println("'" + args[0] + "' is " + filesize1 + " bytes");
        System.out.println("'" + args[1] + "' is " + filesize2 + " bytes");
    }
    // allocate two buffers large enough to hold entire files
    bufsize = (int) Math.min(filesize1, filesize2);
    buffer1 = new byte[bufsize];
    buffer2 = new byte[bufsize];
    try {
        fh1.readFully(buffer1, 0, bufsize);
        fh2.readFully(buffer2, 0, bufsize);

        for (int i = 0; i < bufsize; i++) {
            if (buffer1[i] != buffer2[i]) {
                System.out.println("Files differ at offset " + i);
                break;
            }
        }
    } catch (IOException ioErr) {
        System.err.println("ERROR: An exception occurred while processing the files");
        System.err.println(ioErr);
    } finally {
        try {
            fh1.close();
            fh2.close();
        } catch (IOException ignored) {
        }
    }
}

From source file:NotHelloWorldPanel.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setTitle("NotHelloWorld");
    frame.setSize(300, 200);/* w  w w.j  ava2 s .  co m*/
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    Container contentPane = frame.getContentPane();
    contentPane.add(new NotHelloWorldPanel());

    frame.show();
}