Example usage for java.io IOException printStackTrace

List of usage examples for java.io IOException printStackTrace

Introduction

In this page you can find the example usage for java.io IOException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:de.alpharogroup.duplicate.files.panels.progressbar.ImagePanelTest.java

/**
 * The main method./*from www .ja v  a2s.  c  o  m*/
 *
 * @param args the arguments
 */
public static void main(String[] args) {
    final JFrame frame = new JFrame();
    frame.addWindowListener(new CloseWindow());
    frame.setTitle("ImagePanelTest");

    ApplicationContext ctx = SpringApplicationContext.getInstance().getApplicationContext();
    Resource resource = ctx.getResource("classpath:images/EngineHierarchy.PNG");

    Resource log4jconfig = ctx.getResource("classpath:conf/log4j/log4jconfig.xml");

    try {
        DOMConfigurator.configure(log4jconfig.getURL());
    } catch (FactoryConfigurationError e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    File imageFile = null;
    try {
        imageFile = resource.getFile();
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    BufferedImage image = null;
    try {
        image = javax.imageio.ImageIO.read(imageFile);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    ImagePanel pnlIconPanel = new ImagePanel(image);
    frame.add(pnlIconPanel);
    frame.setBounds(0, 0, 534, 336);
    frame.setVisible(true);
}

From source file:eu.stratosphere.addons.visualization.swt.SWTVisualization.java

public static void main(String[] args) {

    // First, look for -configDir parameter
    String configDir = null;/*w  w w.  java2 s. co  m*/
    for (int i = 0; i < (args.length - 1); i++) {
        if (CONFIG_DIR_PARAMETER.equals(args[i])) {
            configDir = args[i + 1];
            break;
        }
    }

    if (configDir == null) {
        LOG.error("Please specify Nephele configuration directory with " + CONFIG_DIR_PARAMETER);
        System.exit(1);
        return;
    }

    // Try to load global configuration
    GlobalConfiguration.loadConfiguration(configDir);

    final String address = GlobalConfiguration.getString(ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY, null);
    if (address == null) {
        LOG.error("Cannot find address to job manager's RPC service in configuration");
        System.exit(1);
        return;
    }

    final int port = GlobalConfiguration.getInteger(ConfigConstants.JOB_MANAGER_IPC_PORT_KEY, -1);

    if (port < 0) {
        LOG.error("Cannot find port to job manager's RPC service in configuration");
        System.exit(1);
        return;
    }

    final InetSocketAddress inetaddr = new InetSocketAddress(address, port);
    ExtendedManagementProtocol jobManager;
    int queryInterval = -1;
    try {
        jobManager = (ExtendedManagementProtocol) RPC.getProxy(ExtendedManagementProtocol.class, inetaddr,
                NetUtils.getSocketFactory());

        // Get the query interval
        queryInterval = jobManager.getRecommendedPollingInterval().getValue();

    } catch (IOException e) {

        e.printStackTrace();
        System.exit(1);
        return;
    }

    final SWTVisualizationGUI swtVisualizationGUI = new SWTVisualizationGUI(jobManager, queryInterval);
    final Shell shell = swtVisualizationGUI.getShell();
    final Display display = swtVisualizationGUI.getDisplay();
    shell.open();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}

From source file:com.acmutv.ontoqa.GrammalexMain.java

/**
 * The app main method, executed when the program is launched.
 * @param args The command line arguments.
* @throws IllegalAccessException /*  ww  w.ja  v a2s .c om*/
* @throws InstantiationException 
 */
public static void main(String[] args) throws InstantiationException, IllegalAccessException {
    //CliService.handleArguments(args);
    RuntimeManager.registerShutdownHooks(new ShutdownHook());
    try {

        Path path = FileSystems.getDefault().getPath("data/lexicon").toAbsolutePath();
        String currentDirectory = path.toString();
        final JFileChooser fc = new JFileChooser(currentDirectory);

        int returnVal = fc.showOpenDialog(null);
        fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
        if (returnVal == JFileChooser.OPEN_DIALOG) {
            File file = fc.getSelectedFile();
            System.out.println("File Select: " + file.getName() + "\n\n");
            List<LexicalEntry> lEntries = LexiconUsage.getLexicalEntries(file.getAbsolutePath(), "",
                    LexiconFormat.RDFXML);
            Grammar grammar = SerializeSltag.getAllElementarySltag(lEntries);
            SerializeSltag.writeGrammarOnFile(grammar, fileJson);
        }

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    System.exit(0);
}

From source file:zz.pseas.ghost.login.weibo.WeibocnLogin.java

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

    // ?URL//w  w w  .j  av a  2  s .  co m
    String Loginurl = "http://login.weibo.cn/login/";
    String firstpage = "http://weibo.cn/?vt=4"; // ??
    String loginnum = "test";
    String loginpwd = "test";

    CloseableHttpClient httpclient = HttpClients.createDefault(); // 
    HttpGet httpget = new HttpGet(Loginurl);

    try {
        CloseableHttpResponse response = httpclient.execute(httpget);

        String responhtml = null;
        try {
            responhtml = EntityUtils.toString(response.getEntity());
            // System.out.println(responhtml);
        } catch (IOException e1) {
            e1.printStackTrace();
        }

        // vk?,splithtml,??
        String vk = responhtml.split("<input type=\"hidden\" name=\"vk\" value=\"")[1].split("\" /><input")[0];
        System.out.println(vk);

        String pass = vk.split("_")[0];
        String finalpass = "password_" + pass;
        System.out.println(finalpass);
        response.close();

        List<BasicNameValuePair> pairs = new ArrayList<BasicNameValuePair>();
        pairs.add(new BasicNameValuePair("mobile", loginnum));
        pairs.add(new BasicNameValuePair(finalpass, loginpwd));
        pairs.add(new BasicNameValuePair("remember", "on"));
        pairs.add(new BasicNameValuePair("vk", vk));

        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(pairs, Consts.UTF_8); // 
        HttpPost httppost = new HttpPost(Loginurl);
        httppost.setEntity(entity);
        // ???
        CloseableHttpResponse response2 = httpclient.execute(httppost);
        System.out.println(response2.getStatusLine().toString());
        httpclient.execute(httppost); // ?
        System.out.println("success");

        HttpGet getinfo = new HttpGet("http://m.weibo.cn/p/100803?vt=4");
        CloseableHttpResponse res;
        res = httpclient.execute(getinfo);
        System.out.println("??:");
        // ?html
        System.out.println(EntityUtils.toString(res.getEntity()));
        res.close();

    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            httpclient.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:eu.crisis_economics.utilities.EnumDistribution.java

static public void main(String[] args) {
    try {/*from w  ww.j a va 2 s . c o m*/
        EnumDistribution<ScheduleIntervals> dice = EnumDistribution.create(ScheduleIntervals.class,
                "./test.dat");
        EnumMap<ScheduleIntervals, Integer> tallies = new EnumMap<ScheduleIntervals, Integer>(
                ScheduleIntervals.class);
        for (ScheduleIntervals value : ScheduleIntervals.values())
            tallies.put(value, 0);
        final int numSamples = 10000000;
        for (int i = 0; i < numSamples; ++i) {
            ScheduleIntervals value = dice.sample();
            tallies.put(value, tallies.get(value) + 1);
        }
        for (Entry<ScheduleIntervals, Integer> record : tallies.entrySet()) {
            ScheduleIntervals value = record.getKey();
            int tally = tallies.get(value);
            System.out.printf("%20s %16.10g\n", value.name(), tally / (double) numSamples);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:iaj.linkit.App.java

/**
 * Application entry method.//from w  ww  .j a v a  2 s  . co m
 *
 * @param args Command line arguments.
 */
public static void main(final String[] args) {
    final Configuration config = new Configuration();
    final CmdLineParser parser = new CmdLineParser(config);

    try {
        parser.parseArgument(args);

        final File f = (config.getPaths().size() > 0) ? new File(config.getPaths().get(0)).getCanonicalFile()
                : new File(DIR_CURRENT).getCanonicalFile();
        if (!f.exists()) {
            System.err.println("No such path: " + f.getCanonicalFile());
            System.exit(1);
        } else if (!f.canRead()) {
            System.err.println("Can't read path.");
            System.exit(1);
        } else if (f.isDirectory()) {
            handleFiles(config.isRecursive(), f.listFiles());
        } else {
            handleFiles(config.isRecursive(), f);
        }

    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
    } catch (final CmdLineException e) {
        System.err.println(e.getMessage());
        System.err.println("lu [options...] [paths...]"); //$NON-NLS-1$
        parser.printUsage(System.err);
        System.exit(1);
    }
}

From source file:me.rgcjonas.portableMinecraftLauncher.Main.java

/**
 * entry point//from   ww w .j av  a 2s  .com
 * @param args
 */
public static void main(String[] args) {
    File workDir = getWorkingDirectory();

    //ensure the working directory exists
    if (!workDir.exists()) {
        workDir.mkdir();
    }
    File launcherJar = new File(workDir, "launcher.jar");

    //download launcher if it doesn't exist
    if (!launcherJar.exists()) {
        try {
            URL launcherurl = new URL("https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft.jar");
            FileUtils.copyURLToFile(launcherurl, launcherJar);
        } catch (IOException e) {
            // shouldn't happen
            e.printStackTrace();
        }
    }

    URL[] urls;
    try {
        urls = new URL[] { launcherJar.toURI().toURL() };

        //this class loader mustn't be disposed while the launcher is running
        @SuppressWarnings("resource")
        LauncherClassLoader loader = new LauncherClassLoader(urls);

        //run it      
        Class<?> launcherFrame = loader.loadClass("net.minecraft.LauncherFrame");
        launcherFrame.getMethod("main", String[].class).invoke(null, (Object) args);
    } catch (Exception e) {
        // there's nothing we can do in that case but notify the dev
        e.printStackTrace();
    }
}

From source file:mytrack.SimpleModelView.java

public static void main(String[] args) {
    try {//from   www  .j a va 2s  . com
        new SimpleModelView().setVisible(true);
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

From source file:net.iubris.ipc_d3.cap.CamelizeSomeFieldsAndExtractInformazioniStoricheDates.java

public static void main(String[] args) {
    try {/*from   w w  w. j  ava 2 s  . c  om*/
        //         String input = args[0];
        String input = "../../data/data_totale.csv";
        String csvString = FileUtils.readFile(input, Charset.defaultCharset());

        csvString.replace("\"\"\"", "\"");
        JSONArray adjustedTimeAndTipiSpecifici = new CamelizeSomeFieldsAndExtractInformazioniStoricheDates()
                .adjustTimeAndTipiSpecifici(csvString);
        String adjustedTimeAndTipiSpecificiString = adjustedTimeAndTipiSpecifici.toString();
        System.out.println(adjustedTimeAndTipiSpecificiString);
        FileUtils.writeToFile(adjustedTimeAndTipiSpecificiString, "../data_totale_camelized_some_fields.json");

    } catch (IOException e) {
        e.printStackTrace();
    } catch (ParseException e) {
        e.printStackTrace();
    }
}

From source file:XMLInfo.java

public static void main(String args[]) {
    try {/*w w  w .  j  a v a  2s .c o  m*/
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document document = builder.parse("xmlFileName.xml");
        Node root = document.getDocumentElement();
        System.out.print("Here is the document's root node:");
        System.out.println(" " + root.getNodeName());
        System.out.println("Here are its child elements: ");
        NodeList childNodes = root.getChildNodes();
        Node currentNode;

        for (int i = 0; i < childNodes.getLength(); i++) {
            currentNode = childNodes.item(i);
            System.out.println(currentNode.getNodeName());
        }

        // get first child of root element
        currentNode = root.getFirstChild();

        System.out.print("The first child of root node is: ");
        System.out.println(currentNode.getNodeName());

        // get next sibling of first child
        System.out.print("whose next sibling is: ");
        currentNode = currentNode.getNextSibling();
        System.out.println(currentNode.getNodeName());

        // print value of next sibling of first child
        System.out.println("value of " + currentNode.getNodeName() + " element is: "
                + currentNode.getFirstChild().getNodeValue());

        // print name of parent of next sibling of first child
        System.out.print("Parent node of " + currentNode.getNodeName() + " is: "
                + currentNode.getParentNode().getNodeName());
    }
    // handle exception creating DocumentBuilder
    catch (ParserConfigurationException parserError) {
        System.err.println("Parser Configuration Error");
        parserError.printStackTrace();
    }

    // handle exception reading data from file
    catch (IOException fileException) {
        System.err.println("File IO Error");
        fileException.printStackTrace();
    }

    // handle exception parsing XML document
    catch (SAXException parseException) {
        System.err.println("Error Parsing Document");
        parseException.printStackTrace();
    }
}