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:com.github.wolfposd.jdpkg.deb.DpkgDeb.java

public static String getPackageName() {
    File controlFile = new File(BuildFile + "/DEBIAN/control");

    String packageName = BuildFile;

    try (Scanner scan = new Scanner(controlFile)) {
        String line = "";
        while (scan.hasNextLine()) {
            line = scan.nextLine();/*from w w  w  .j  a va2 s.c o m*/
            if (line.toLowerCase().startsWith("package:")) {
                packageName = line.replace("Package:", "").trim();
                break;
            }
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

    return packageName;
}

From source file:com.sun.portal.os.portlets.PortletChartUtilities.java

private static void writeDefaultImage(OutputStream out, String defaultImagePath) throws IOException {

    FileInputStream fin = null;/*ww  w . jav  a 2s. co m*/
    try {
        byte[] b = new byte[1024];
        fin = new FileInputStream(defaultImagePath);
        while (fin.read(b) != -1) {
            out.write(b);
        }
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        fin.close();
    }
}

From source file:application.gen.gen.java

public static void genMybatisFile(List<Table> tableList, ConnObj obj) {
    Properties pros = new Properties();
    String configPath = "";
    try {/*from   w  w  w . java  2s  .  c  o m*/
        pros.load(new FileInputStream("RelicConfig" + File.separator + "velocity.properties"));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        System.out.println("cant found the velocity.properties");
        e.printStackTrace();
    }
    Velocity.init(pros);

    VelocityContext context = new VelocityContext();
    for (application.bean.Template tem : Context.templateList.getTemplates()) {
        if (tableList.get(0).getDbType().equalsIgnoreCase(tem.getDbType()) && tem.getType() == 2) {
            context.put("driver", obj.getDbConfiguration().getDriver());
            context.put("tableList", tableList);
            context.put("cDir", Context.cDir);
            context.put("schema", obj.getSchema());
            context.put("dbConfiguration", obj.getDbConfiguration());
            context.put("url", obj.getDbConfiguration().getUrl()
                    + (obj.getCatalog() == null ? "" : "/" + obj.getCatalog()));
            configPath = tem.getGenDir() + tem.getNamePre() + "generatorConfigMyBatis" + tem.getNameSuf();
            gen(context, tem.getTemplatePath(), configPath);
        }
    }
    MybatisUtil.genMybatis(configPath);
}

From source file:com.sarm.lonelyplanet.common.GeoUtilsTest.java

/**
 * This is the initialization step of this test class.This test depends on
 * the sample test file that is provided in the test.properties. It is
 * designed to be a certain subset for these tests to pass.
 *
 *//* w ww.  j a  va  2 s . c  o m*/
@BeforeClass
public static void setUpClass() {
    Properties prop = new Properties();
    logger.info("GeoUtilsTest : Commencing loading test properties ...");
    String propFileName = LonelyConstants.testPropertyFile;

    try (InputStream input = new FileInputStream(propFileName)) {

        if (input == null) {
            logger.debug("input Stream for test.properties file : is Null  ");
            throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
        }
        prop.load(input);

    } catch (FileNotFoundException ex) {
        ex.printStackTrace();

        logger.debug("");
    } catch (IOException ex) {
        logger.debug("");
    }
    taxonomyFileName = prop.getProperty(LonelyConstants.propertyTaxonomy);
    destinationTitle = prop.getProperty(LonelyConstants.destinationTitle);
    parentLink = prop.getProperty(LonelyConstants.parentLink);
    childrenLink = prop.getProperty(LonelyConstants.childrenLink);
    sampleDestinationHtml = prop.getProperty(LonelyConstants.sampleDestinationHtml);

    try {
        taxonomies = TaxonomyProcessor.processTaxonomy(taxonomyFileName);
    } catch (FileNotFoundException ex) {
        logger.debug("FileNotFoundException  on file  : " + taxonomyFileName);
        ex.printStackTrace();
    } catch (JAXBException ex) {
        logger.debug("JAXBException  : ");
        ex.printStackTrace();
    }
    populateParentNode = taxonomies.getTaxonomy().getNodesInTaxonomy().get(0).getChildrenNodes().get(0)
            .getChildrenNodes().get(0);
    navigateIntoChildrenNode = taxonomies.getTaxonomy().getNodesInTaxonomy().get(0);
}

From source file:application.gen.gen.java

public static void genFile(List<Table> tableList) {
    Properties pros = new Properties();
    try {// w  w  w. j  av a2 s  . c  o  m
        pros.load(new FileInputStream("RelicConfig" + File.separator + "velocity.properties"));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        System.out.println("cant found the velocity.properties");
        e.printStackTrace();
    }
    Velocity.init(pros);

    VelocityContext context = new VelocityContext();
    for (application.bean.Template tem : Context.templateList.getTemplates()) {
        for (Table table : tableList) {
            if (table.getDbType().equalsIgnoreCase(tem.getDbType())) {
                context.put("cDir", Context.cDir);
                context.put("schemaName", "main");
                context.put("proName",
                        tem.getNamePre() + table.getTABLE_NAMEFU() + tem.getNameSuf().replace(".sql", ""));
                context.put("tableName", table.getTABLE_NAME());
                context.put("tableNameFU", table.getTABLE_NAMEFU());
                context.put("tableNameFL", table.getTABLE_NAMEFL());
                context.put("columns", table.getColumns());
                context.put("table", table);
                gen(context, tem.getTemplatePath(),
                        tem.getGenDir() + tem.getNamePre() + table.getTABLE_NAMEFU() + tem.getNameSuf());

            }
        }
    }
}

From source file:com.ExtendedAlpha.SWI.SeparatorLib.InventorySeparator.java

public static ItemStack[] getInventory(File jsonFile, int size) {
    String source = "";
    try {//from   ww w.j a v  a2 s . co  m
        Scanner x = new Scanner(jsonFile);
        while (x.hasNextLine()) {
            source += x.nextLine() + "\n";
        }
        x.close();
        return getInventory(source, size);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.oculusinfo.ml.spark.unsupervised.TestKMeans.java

public static void genTestData(int k) {
    PrintWriter writer;/*w  w  w  . j  av a  2 s. c  o m*/
    try {
        writer = new PrintWriter("test.txt", "UTF-8");

        // each class size is equal 
        int classSize = 1000000 / k;

        double stdDev = 30.0;

        // generate k classes of data points using a normal distribution with random means and fixed std deviation
        for (int i = 0; i < k; i++) {
            Random rnd = new Random();

            double meanX = rnd.nextDouble() * 400.0;
            double meanY = rnd.nextDouble() * 400.0;

            // randomly generate a dataset of x, y points
            for (int j = 0; j < classSize; j++) {
                double x = rnd.nextGaussian() * stdDev + meanX;
                double y = rnd.nextGaussian() * stdDev + meanY;

                writer.println(x + "," + y);
            }
        }
        writer.close();
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.sarm.Travelogue.process.DestinationProcessorRegressorTest.java

@BeforeClass
public static void setUpClass() {
    logger.info("DestinationProcessorRegressorTest  Commencing loading test properties ...");
    Properties prop = new Properties();

    String propFileName = LonelyConstants.testPropertyFile;

    try (InputStream input = new FileInputStream(propFileName)) {

        if (input == null) {
            logger.debug("input Stream for test.properties file : is Null  ");
            throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
        }//ww w .j  a  v  a2 s.  c o  m
        logger.debug("Loading properties file   " + propFileName);

        prop.load(input);
    } catch (FileNotFoundException ex) {
        logger.debug("FileNotFoundException  " + propFileName);
        ex.printStackTrace();
    } catch (IOException ex) {
        logger.debug("IOException  " + propFileName);
        ex.printStackTrace();
    }

    regressDestinationfile = prop.getProperty(LonelyConstants.regressDestinationfile);

    try {
        testMarshall(".//destinations.xml");
    } catch (JAXBException | FileNotFoundException | XMLStreamException | UnsupportedEncodingException ex) {
        ex.printStackTrace();

    }

}

From source file:IO.java

public static int[] readIntVec(File file, int nData) {
    int[] data = new int[nData];
    try {// w  ww .j ava 2  s .  c o  m
        Scanner sc = new Scanner(file);
        sc.useDelimiter(",|\\n");

        for (int i = 0; i < nData; i++) {
            data[i] = sc.nextInt();
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    return data;
}

From source file:IO.java

public static double[][] readDoubleMat(File file, int row, int col) {
    double[][] data = new double[row][col];
    try {/*  w  w  w.j  a  v a  2s  .c  om*/
        Scanner sc = new Scanner(file);
        sc.useDelimiter(",|\\n");

        for (int i = 0; i < row; i++)
            for (int j = 0; j < col; j++) {
                data[i][j] = Double.parseDouble(sc.next());
            }

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    return data;
}