Example usage for java.io FileNotFoundException printStackTrace

List of usage examples for java.io FileNotFoundException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:GrowBufferedReader.java

public static void main(String... args) {
    try {//from www. ja  va 2s  .co m
        BufferedReader br = new BufferedReader(car);

        Class<?> c = br.getClass();
        Field f = c.getDeclaredField("cb");

        // cb is a private field
        f.setAccessible(true);
        char[] cbVal = char[].class.cast(f.get(br));

        char[] newVal = Arrays.copyOf(cbVal, cbVal.length * 2);
        if (args.length > 0 && args[0].equals("grow"))
            f.set(br, newVal);

        for (int i = 0; i < srcBufSize; i++)
            br.read();

        // see if the new backing array is being used
        if (newVal[srcBufSize - 1] == src[srcBufSize - 1])
            out.format("Using new backing array, size=%d%n", newVal.length);
        else
            out.format("Using original backing array, size=%d%n", cbVal.length);

        // production code should handle these exceptions more gracefully
    } catch (FileNotFoundException x) {
        x.printStackTrace();
    } catch (NoSuchFieldException x) {
        x.printStackTrace();
    } catch (IllegalAccessException x) {
        x.printStackTrace();
    } catch (IOException x) {
        x.printStackTrace();
    }
}

From source file:Ch7_Images.java

public static void main(String[] args) {
    int numRows = 6, numCols = 11, pix = 20;
    PaletteData pd = new PaletteData(
            new RGB[] { new RGB(0x00, 0x00, 0x00), new RGB(0x80, 0x80, 0x80), new RGB(0xFF, 0xFF, 0xFF) });

    ImageData[] flagArray = new ImageData[3];
    for (int frame = 0; frame < flagArray.length; frame++) {
        flagArray[frame] = new ImageData(pix * numCols, pix * numRows, 4, pd);
        flagArray[frame].delayTime = 10;
        for (int x = 0; x < pix * numCols; x++) {
            for (int y = 0; y < pix * numRows; y++) {
                int value = (((x / pix) % 3) + (3 - ((y / pix) % 3)) + frame) % 3;
                flagArray[frame].setPixel(x, y, value);
            }//w  ww.j a  v  a 2 s .  c o  m
        }
    }

    ImageLoader gifloader = new ImageLoader();
    ByteArrayOutputStream flagByte[] = new ByteArrayOutputStream[3];
    byte[][] gifarray = new byte[3][];
    gifloader.data = flagArray;

    for (int i = 0; i < 3; i++) {
        flagByte[i] = new ByteArrayOutputStream();
        flagArray[0] = flagArray[i];
        gifloader.save(flagByte[i], SWT.IMAGE_GIF);
        gifarray[i] = flagByte[i].toByteArray();
    }

    byte[] gif = new byte[4628];
    System.arraycopy(gifarray[0], 0, gif, 0, 61);
    System.arraycopy(new byte[] { 33, (byte) 255, 11 }, 0, gif, 61, 3);
    System.arraycopy("NETSCAPE2.0".getBytes(), 0, gif, 64, 11);
    System.arraycopy(new byte[] { 3, 1, -24, 3, 0, 33, -7, 4, -24 }, 0, gif, 75, 9);
    System.arraycopy(gifarray[0], 65, gif, 84, 1512);

    for (int i = 1; i < 3; i++) {
        System.arraycopy(gifarray[i], 61, gif, 1516 * i + 80, 3);
        gif[1516 * i + 83] = (byte) -24;
        System.arraycopy(gifarray[i], 65, gif, 1516 * i + 84, 1512);
    }

    try {
        DataOutputStream in = new DataOutputStream(
                new BufferedOutputStream(new FileOutputStream(new File("FlagGIF.gif"))));
        in.write(gif, 0, gif.length);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:ImageLoadingFromFileInputStream.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Canvas Example");
    shell.setLayout(new FillLayout());

    Canvas canvas = new Canvas(shell, SWT.NONE);

    canvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            Image image = null;/*from w w w.j  av  a  2 s. co  m*/
            try {
                image = new Image(display, new FileInputStream("yourFile.gif"));
            } catch (FileNotFoundException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            e.gc.drawImage(image, 10, 10);

            image.dispose();
        }
    });

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

From source file:CharsetDetector.java

public static void main(String[] args) {
    File f = new File("example.txt");

    String[] charsetsToBeTested = { "UTF-8", "windows-1253", "ISO-8859-7" };

    CharsetDetector cd = new CharsetDetector();
    Charset charset = cd.detectCharset(f, charsetsToBeTested);

    if (charset != null) {
        try {/*from www.j  a v a 2s  .c  om*/
            InputStreamReader reader = new InputStreamReader(new FileInputStream(f), charset);
            int c = 0;
            while ((c = reader.read()) != -1) {
                System.out.print((char) c);
            }
            reader.close();
        } catch (FileNotFoundException fnfe) {
            fnfe.printStackTrace();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }

    } else {
        System.out.println("Unrecognized charset.");
    }
}

From source file:com.st.si.Main.java

/**
 * Load the Spring Integration Application Context
 *
 * @param args - command line arguments/*from  w  w  w  .  j a v  a 2 s .  com*/
 */
public static void main(final String... args) {

    final AbstractApplicationContext context = new ClassPathXmlApplicationContext(
            "classpath:META-INF/spring/integration/*-context.xml");

    context.registerShutdownHook();
    DefaultSftpSessionFactory sftpSessionFactory = context.getBean(DefaultSftpSessionFactory.class);

    SftpSession session = sftpSessionFactory.getSession();
    final DirectChannel requestChannel = (DirectChannel) context.getBean("inboundMGetRecursive");
    //final PollableChannel replyChannel = (PollableChannel) context.getBean("output");

    try {
        String dir = "/HVAC - Files For Testing/";
        requestChannel.send(new GenericMessage<Object>(dir + "*"));
        /*if (!session.exists(sftpConfiguration.getOtherRemoteDirectory())) {
           throw new FileNotFoundException("Remote directory does not exists... Continuing");
        }*/

        rename(session, dir);

        dir = "/HPwES - Files For Testing/";
        requestChannel.send(new GenericMessage<Object>(dir + "*"));
        rename(session, dir);

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

    /*final DirectChannel requestChannel = (DirectChannel) context.getBean("inboundMGetRecursive");
    final PollableChannel replyChannel = (PollableChannel) context.getBean("output");
            
            
    String dir = "/HVAC - Files For Testing/";
    requestChannel.send(new GenericMessage<Object>(dir + "*"));
    Message<?> result = replyChannel.receive(1000);
            
    List<File> localFiles = (List<File>) result.getPayload();
            
    for (File file : localFiles) {
       System.out.println(file.getName());
    }*/

    System.exit(0);

}

From source file:com.web.server.ShutDownServer.java

/**
 * @param args// w  ww .j ava2s  .c o m
 * @throws SAXException 
 * @throws IOException 
 */
public static void main(String[] args) throws IOException, SAXException {
    DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() {

        protected void loadRules() {
            // TODO Auto-generated method stub
            try {
                loadXMLRules(new InputSource(new FileInputStream("./config/serverconfig-rules.xml")));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }
    });
    Digester serverdigester = serverdigesterLoader.newDigester();
    ServerConfig serverconfig = (ServerConfig) serverdigester
            .parse(new InputSource(new FileInputStream("./config/serverconfig.xml")));
    try {
        Socket socket = new Socket("localhost", Integer.parseInt(serverconfig.getShutdownport()));
        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("shutdown WebServer\r\n\r\n".getBytes());
        outputStream.close();
    } catch (IOException e1) {

        e1.printStackTrace();
    }

}

From source file:clases.Main.java

public static void main(String[] args) {
    try {/*from w w  w.jav  a  2 s .c  o m*/
        Manejador admin = new Manejador();
        admin.setRuta("notebooks.json");
        admin.Conectar();
        admin.setNom_bd("notebooks");
        admin.setNom_coleccion("notebooks");

        DateFormat format_date = new SimpleDateFormat("yyyy-MM-dd");
        Date fecha = new Date();
        String date_now = format_date.format(fecha);

        JSONObject param_1 = new JSONObject("{id_notebook: 1}");

        JSONObject busqueda = admin.Select(param_1);

        if (busqueda.has("id") && busqueda.get("id").equals(0)) {
            System.out.println(busqueda.toString(4));

        } else {
            JSONObject[] obj_param_arr = { new JSONObject("{ notes: [{id_note: 1}] }"),
                    new JSONObject("{ prueba: [{id_pedo: 1}] }") };

            JSONObject nota = admin.SelectIntoArray(busqueda, obj_param_arr[0]);

            String claves = "\"HESOYAM\\nLXGIWYL\"";
            String str_js = "{ notes: [{titulo: Claves GTA San andreas PC, note: " + claves
                    + ", fecha_modificacion: " + date_now + "}] }";

            String str_js2 = "{ prueba: [{texto: HOla}] }";
            String str_js3 = "{ notes: [{note: \"No c, weno si c pero no te wa decir\"}] }";

            String[] arr_changes = { str_js, str_js2, str_js3 };

            /*JSONObject cambios = new JSONObject(arr_changes[2]);
            boolean exito = admin.updateIntoArray(nota, cambios);
                    
            if(exito) {
            System.out.println("Registro editado de manera satisfactoria!");
                    
            } else {
            System.out.println("Registro no encontrado");
            }*/

            String[] targets = { "{ notes: [{id_note: 1}] }" };

            //admin.delete(param_1);
            JSONObject target = new JSONObject(targets[0]);
            admin.deleteIntoArray(busqueda, target);
        }

        /*
        JSONObject cambio = new JSONObject("{nombre: Cronicas Rata, fecha_modificacion: \""+ date_now +"\"}");
        boolean exito = admin.update(new JSONObject("{id_notebook: 2}"), cambio);
                
        if(exito) {
        System.out.println("Registro modificado de manera satisfactoria");
        }*/
    } catch (FileNotFoundException fe) {
        fe.printStackTrace();

    } catch (IOException ioe) {
        ioe.printStackTrace();

    } catch (JSONException je) {
        je.printStackTrace();
    }

}

From source file:eu.planets_project.pp.plato.services.characterisation.xcl.Comparator.java

public static void main(String[] args) {
    Comparator comp = new Comparator();
    try {/* w  w  w. j a va2 s .  c om*/
        InputStream in = new FileInputStream(
                "d:/workspace/plato/data/pp5/polarbear1.tiff.xcdl-vs-polarbear1.tiff.xcdl.cpr");
        ComparatorUtils compUtils = new ComparatorUtils();
        List<CompareResult> result = compUtils
                .parseResponse("d:/workspace/plato/data/pp5/polarbear1.tiff.xcdl-vs-polarbear1.tiff.xcdl.cpr");
        System.out.print("num of comps: " + result.size());
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (PlatoServiceException e) {
        e.printStackTrace();
    }

}

From source file:com.qualogy.qafe.bind.io.document.LocalXSDResolver.java

public static void main(String[] args) {
    try {/*from  w w w  .  j  av  a2s  . c  o m*/
        InputStream is = new FileInputStream(
                "/media/Data/develop/svn/qafe/platform/trunk/qafe-core/src/main/resources/application-context.xsd");
        System.out.print(new LocalXSDResolver().resolveToLocalXSDs(is));
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.ibm.iot.auto.bluemix.samples.ui.MapView.java

public static void main(String[] args) {
    String inputFile = null;//from  w  w w . j a  va 2  s. c om
    String jobId = null;
    for (int i = 0; i < args.length; i++) {
        if ("--input_file".equalsIgnoreCase(args[i])) {
            inputFile = args[i + 1];
        } else if ("--job_id".equalsIgnoreCase(args[i])) {
            jobId = args[i + 1];
        }
    }
    if (inputFile == null) {
        inputFile = INPUT_FILE;
    }
    if (jobId == null) {
        System.err.println(
                "usage: java -jar mapview.jar --job_id <job ID> [--input_file <driving data JSON file>]");
        return;
    }

    Configuration config = null;
    try {
        config = new Configuration(CONFIG_FILE);

        InputData inputData = new InputData(inputFile);
        carProbes = inputData.getCarProbes();

        DriverService service = new DriverService(config);

        List<String> tripUuIds = service.getAllTripUuIds(jobId);
        String tripUuId = tripUuIds.get(0);
        driverBehaviorDetails = service.getAllDriverBehaviorDetails(tripUuId);

        String[] arguments = { MapView.class.getName() };
        PApplet.main(arguments);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}