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:Main.java

public static void main(String[] args) {
    String path = System.getProperty("user.dir", ".");

    File dir = new File(path);

    JFileChooser jfc = new JFileChooser(dir);
    int result = jfc.showOpenDialog(null);

    switch (result) {
    case JFileChooser.CANCEL_OPTION:
        System.out.println("User cancelled OPEN dialog.");
        break;//from   w  w w  .j a  v a 2  s . c om
    case JFileChooser.APPROVE_OPTION:
        System.out.println("User chose file: " + jfc.getSelectedFile());
        break;
    case JFileChooser.ERROR_OPTION:
        System.out.println("User encountered an error");
        break;
    default:
        System.out.println("Confused");
        break;
    }

    System.exit(0);
}

From source file:LabelForComboBox.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }/*from www. j av a2s  . co  m*/
    });
    f.getContentPane().add(new LabelForComboBox());
    f.pack();
    f.setSize(new Dimension(300, 200));
    f.show();

}

From source file:GZIPcompress.java

public static void main(String[] args) throws IOException {
    if (args.length == 0) {
        System.out.println("Usage: \nGZIPcompress file\n" + "\tUses GZIP compression to compress "
                + "the file to test.gz");
        System.exit(1);
    }/*from   w ww.java2  s .  c  o m*/
    BufferedReader in = new BufferedReader(new FileReader(args[0]));
    BufferedOutputStream out = new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream("test.gz")));
    System.out.println("Writing file");
    int c;
    while ((c = in.read()) != -1)
        out.write(c);
    in.close();
    out.close();
    System.out.println("Reading file");
    BufferedReader in2 = new BufferedReader(
            new InputStreamReader(new GZIPInputStream(new FileInputStream("test.gz"))));
    String s;
    while ((s = in2.readLine()) != null)
        System.out.println(s);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
    StringSelection testData = new StringSelection("Test Data");

    c.setContents(testData, testData);// www . j a v  a2s . c o  m
    // Get clipboard contents, as a String
    Transferable t = c.getContents(null);
    if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
        Object o = t.getTransferData(DataFlavor.stringFlavor);
        String data = (String) t.getTransferData(DataFlavor.stringFlavor);
        System.out.println("Clipboard contents: " + data);
    }
    System.exit(0);
}

From source file:BasicStrokeDemo.java

public static void main(String s[]) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }/*from ww w  .  j  a  v a  2  s.  c  om*/
    });
    BasicStrokeDemo p = new BasicStrokeDemo();
    f.getContentPane().add("Center", p);
    p.init();
    f.pack();
    f.setSize(new Dimension(250, 250));
    f.show();
}

From source file:ThickStrokeDemo.java

public static void main(String s[]) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }/*from  w w  w.  j a  va2 s.c  o m*/
    });
    ThickStrokeDemo p = new ThickStrokeDemo();
    f.getContentPane().add("Center", p);
    p.init();
    f.pack();
    f.setSize(new Dimension(250, 250));
    f.show();
}

From source file:fi.jumi.launcher.JumiBootstrap.java

public static void main(String[] args) throws Exception {
    try {//from  w w w  .  j a  va  2  s.  c  o  m
        JumiBootstrap bootstrap = new JumiBootstrap();
        bootstrap.suite.addJvmOptions("-ea").setTestClasses(args);
        bootstrap.runSuite();
    } catch (AssertionError e) {
        System.exit(1);
    }
}

From source file:Main.java

public static void main(String[] argv) {
    JFrame frame = new Main();
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }/*from w  ww. jav  a2 s. c  om*/
    });

    frame.pack();
    frame.setVisible(true);
}

From source file:SVGDOC2JPEG.java

public static void main(String[] args) throws Exception {

    JPEGTranscoder transcoder = new JPEGTranscoder();

    transcoder.addTranscodingHint(JPEGTranscoder.KEY_XML_PARSER_CLASSNAME,
            "org.apache.crimson.parser.XMLReaderImpl");
    transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(1.0));

    TranscoderInput input = new TranscoderInput(new FileInputStream("rectangles.svg"));
    OutputStream ostream = new FileOutputStream("out.jpg");
    TranscoderOutput output = new TranscoderOutput(ostream);

    transcoder.transcode(input, output);
    ostream.close();// w ww . ja  v a 2 s  .  co  m
    System.exit(0);
}

From source file:MainClass.java

public static void main(String args[]) {
    FileInputStream fileInputStream;
    FileChannel fileChannel;/*from   w  w  w  .ja  va  2s  .  c o  m*/
    long fileSize;
    MappedByteBuffer mBuf;

    try {
        fileInputStream = new FileInputStream("test.txt");
        fileChannel = fileInputStream.getChannel();
        fileSize = fileChannel.size();
        mBuf = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fileSize);

        for (int i = 0; i < fileSize; i++)
            System.out.print((char) mBuf.get());

        fileChannel.close();
        fileInputStream.close();
    } catch (IOException exc) {
        System.out.println(exc);
        System.exit(1);
    }
}