Example usage for java.io FileNotFoundException getMessage

List of usage examples for java.io FileNotFoundException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.amazonaws.mturk.cmd.GenerateResultsSummary.java

/**
 * Writes the given summary to the specified summary file.
 * @param summaryFields The summary column names.
 * @param summary Summary of a sample's results.
 * @param summaryFilename Name of the file to which the summary is to be written.
 *///from  www. j ava2 s.com
private void writeSummary(List<String> summaryFields, Map<String, List<String>> summary,
        String summaryFilename) {

    PrintWriter pw = null;
    try {
        pw = new PrintWriter(new FileOutputStream(summaryFilename));
        // print in tab-delimited format
        {
            String headerRowCsv = StringUtils.join(summaryFields, "\t");
            // add the manageHIT URL as the last column
            pw.println(headerRowCsv + "\tManage HIT");
        }

        for (Map.Entry<String, List<String>> hitSummary : summary.entrySet()) {
            String hitId = hitSummary.getKey();
            String summaryCsv = StringUtils.join(hitSummary.getValue(), "\t");
            // add the manage-hit URL as the last column
            String manageHITUrl = getManageHITUrl(hitId);
            pw.println(summaryCsv + "\t" + manageHITUrl);
        }

    } catch (FileNotFoundException e) {
        log.error("An error occurred while writing the results summary: " + e.getMessage(), e);
        System.exit(-1);
    } finally {
        if (pw != null) {
            pw.close();
        }
    }
}

From source file:gsn.wrappers.GPSGenerator.java

public boolean initialize() {
    AddressBean addressBean = getActiveAddressBean();
    if (addressBean.getPredicateValue("rate") != null) {
        samplingRate = ParamParser.getInteger(addressBean.getPredicateValue("rate"), DEFAULT_SAMPLING_RATE);
        if (samplingRate <= 0) {
            logger.warn(//from  w  w w. j a va2s  . com
                    "The specified >sampling-rate< parameter for the >MemoryMonitoringWrapper< should be a positive number.\nGSN uses the default rate ("
                            + DEFAULT_SAMPLING_RATE + "ms ).");
            samplingRate = DEFAULT_SAMPLING_RATE;
        }
    }
    if (addressBean.getPredicateValue("picture") != null) {
        String picture = addressBean.getPredicateValue("picture");
        File pictureF = new File(picture);
        if (!pictureF.isFile() || !pictureF.canRead()) {
            logger.warn("The GPSGenerator can't access the specified picture file. Initialization failed.");
            return false;
        }
        try {
            BufferedInputStream fis = new BufferedInputStream(new FileInputStream(pictureF));
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            byte[] buffer = new byte[4 * 1024];
            while (fis.available() > 0)
                outputStream.write(buffer, 0, fis.read(buffer));
            fis.close();
            this.picture = outputStream.toByteArray();
            outputStream.close();
        } catch (FileNotFoundException e) {
            logger.warn(e.getMessage(), e);
            return false;
        } catch (IOException e) {
            logger.warn(e.getMessage(), e);
            return false;
        }
    } else {
        logger.warn("The >picture< parameter is missing from the GPSGenerator wrapper.");
        return false;
    }
    ArrayList<DataField> output = new ArrayList<DataField>();
    for (int i = 0; i < FIELD_NAMES.length; i++)
        output.add(new DataField(FIELD_NAMES[i], FIELD_TYPES_STRING[i], FIELD_DESCRIPTION[i]));
    outputStrcture = output.toArray(new DataField[] {});
    return true;
}

From source file:gui.accessories.DownloadProgressWork.java

@Override
public Void doInBackground() throws FileNotFoundException {
    setProgress(0);/*from   ww w  . j  a  va 2  s .  c o  m*/
    try {
        Thread.sleep(1000);
        downloadFile = new File(new File(portraitsFolder), portraitsFileName);
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    downloadFile = portraitsService.downloadPortraisFile(portraitsFileName, portraitsFolder);
                    filesCount = doUncompressZip(downloadFile);
                } catch (FileNotFoundException ex) {
                    LOG.error("Qu mal todo. " + ex.getMessage());
                } catch (ZipException ex) {
                    LOG.error("Qu mal todo descomprimiendo. " + ex.getMessage());
                }
            }
        });
        t.start();
        while (t.isAlive()) {
            Float progreso = downloadFile.length() / (float) fileSize;
            progreso *= 100;
            int progress = progreso.intValue();

            setProgress(progress);
        }

    } catch (InterruptedException ignore) {
    }
    return null;
}

From source file:org.centralperf.service.BootstrapService.java

public void importSamples() {

    // Create sample Projet
    Project sampleProject = new Project();
    sampleProject.setName("Sample project");
    sampleProject.setDescription("Central Perf default sample Project");
    projectService.addProject(sampleProject);

    // Associate sample script
    // Load sample JMX and Gatling files
    String jmxContent;/*  w  w w .  ja v  a2  s  . c  o  m*/
    String gatlingContent;
    try {
        jmxContent = new Scanner(bootstrapServiceFiles.getSampleJMXFile().getFile()).useDelimiter("\\Z").next();
        scriptService.addScript(sampleProject, JMeterSampler.UID, "JMETER Sample script",
                "Central Perf sample JMETER script. Queries a single URL with few scenario's parameters",
                jmxContent);
        gatlingContent = new Scanner(bootstrapServiceFiles.getSampleGatlingFile().getFile()).useDelimiter("\\Z")
                .next();
        scriptService.addScript(sampleProject, GatlingSampler.UID, "GATLING Sample script",
                "Central Perf sample script. Queries Google; only for demonstration (no parameters)",
                gatlingContent);
    } catch (FileNotFoundException e) {
        log.error("Error on bootstrap import:" + e.getMessage(), e);
    } catch (IOException e) {
        log.error("IO Error on bootstrap import:" + e.getMessage(), e);
    }

    // Import sample resuts
    // TODO : Import sample result
}

From source file:org.ngrinder.monitor.service.MonitorService.java

/**
 * Get all{@link SystemDataModel} from monitor data file of one test and target.
 * @param testId/*from   w  ww .ja v a 2s. c  o  m*/
 *             test id
 * @param monitorIP
 *             IP address of the monitor target
 * @return SystemDataModel list
 */
public List<SystemDataModel> getSystemMonitorData(long testId, String monitorIP) {
    LOG.debug("Get SystemMonitorData of test:{} ip:{}", testId, monitorIP);
    List<SystemDataModel> rtnList = new ArrayList<SystemDataModel>();

    File monitorDataFile = new File(config.getHome().getPerfTestReportDirectory(String.valueOf(testId)),
            Config.MONITOR_FILE_PREFIX + monitorIP + ".data");
    BufferedReader br = null;
    try {
        br = new BufferedReader(new FileReader(monitorDataFile));
        br.readLine(); //skip the header.
        //header: "ip,system,collectTime,freeMemory,totalMemory,cpuUsedPercentage"
        String line = br.readLine();
        while (StringUtils.isNotBlank(line)) {
            SystemDataModel model = new SystemDataModel();
            String[] datalist = StringUtils.split(line, ",");
            model.setIp(datalist[0]);
            model.setSystem(datalist[1]);
            model.setCollectTime(Long.valueOf(datalist[2]));
            model.setFreeMemory(Long.valueOf(datalist[3]));
            model.setTotalMemory(Long.valueOf(datalist[4]));
            model.setCpuUsedPercentage(Float.valueOf(datalist[5]));
            rtnList.add(model);
            line = br.readLine();
        }
    } catch (FileNotFoundException e) {
        LOG.error("Monitor data file not exist:{}", monitorDataFile);
        LOG.error(e.getMessage(), e);
    } catch (IOException e) {
        LOG.error("Error while getting monitor:{} data file:{}", monitorIP, monitorDataFile);
        LOG.error(e.getMessage(), e);
    } finally {
        IOUtils.closeQuietly(br);
    }
    LOG.debug("Finish getSystemMonitorData of test:{} ip:{}", testId, monitorIP);
    return rtnList;
}

From source file:edu.clemson.lph.civet.addons.VspsCviFile.java

/**
 * Test only//w  w w  . j a va 2s.  c  o m
 */
private void printme(File fIn) {
    try {
        CSVParser parserIn = new CSVParser(new FileReader(fIn), CSVFormat.EXCEL);
        parser = new LabeledCSVParser(parserIn);
        aCols = parser.getNext();
    } catch (FileNotFoundException e) {
        logger.error(e.getMessage() + "\nCould not read file: " + fIn.getName());
    } catch (IOException e) {
        logger.error(e.getMessage() + "\nCould not read file: " + fIn.getName());
    }
    VspsCvi cvi;
    try {
        while ((cvi = nextCVI()) != null) {
            if (cvi.getStatus().equals("SAVED"))
                continue;
            VspsCviEntity orig = cvi.getOrigin();
            VspsCviEntity dest = cvi.getDestination();
            System.out.println(cvi.getCVINumber() + " created: " + cvi.getCreateDate());
            System.out
                    .println("  origin = " + orig.getName() + " " + orig.getPhone() + " " + orig.getAddress1());
            System.out.println(
                    "  destination = " + dest.getName() + " " + dest.getPhone() + " " + dest.getAddress1());
            System.out.println(cvi.getOriginState() + " " + orig.getState());
            System.out.println(
                    cvi.getVeterinarianName() + ": " + cvi.getVetFirstName() + " " + cvi.getVetLastName());
            System.out.println(cvi.getAnimals().size() + " Animals in CVI");
            System.out.println(cvi.getRemarks());
            for (List<String> aKey : cvi.getSpecies().keySet()) {
                Integer iCount = cvi.getSpecies().get(aKey);
                System.out.println(iCount + " " + aKey.get(0) + " (" + aKey.get(1) + ")");
            }
            for (VspsCviAnimal animal : cvi.getAnimals()) {
                System.out.println("\t" + animal.getSpecies() + " " + animal.getBreed() + " "
                        + animal.getGender() + " " + animal.getDateOfBirth());
                for (int i = 1; i <= 5; i++) {
                    String sIdType = animal.getIdentifierType(i);
                    if (sIdType != null)
                        System.out.println("\t\t" + sIdType + " = " + animal.getIdentifier(i));
                }
            }
        }
    } catch (IOException e) {
        logger.error(e);
    }
}

From source file:com.halseyburgund.rwframework.util.RWMultipartEntity.java

public void addPart(final String key, final File value) {
    try {/*from w w w . j  a  v  a 2  s .  c  o m*/
        addPart(key, value.getName(), new FileInputStream(value));
    } catch (final FileNotFoundException e) {
        Log.e(TAG, e.getMessage(), e);
    }
}

From source file:org.sbs.util.BinaryDateDwonLoader.java

/**
 * @param url//from  w w  w .  j a  v  a2 s.  com
 * @param distPath
 * @return
 * ????
 */
public String download(String url, String distPath) {
    PageFetchResult result = fetchHeader(url);
    if (null != result && null != result.getEntity()) {
        String fileName = EncryptUtils.encodeMD5(url);
        File path = new File(distPath);
        if (!path.exists()) {
            path.mkdirs();
        }
        String file = distPath + File.separator + fileName + url.substring(url.lastIndexOf('.'));
        File imgFile = new File(file);

        try {
            OutputStream outputStream = new FileOutputStream(imgFile);
            result.getEntity().writeTo(outputStream);
            outputStream.close();
            Thumbnails.of(file).width(200).outputQuality(0.6f).toFile(file);
            return imgFile.getName();
        } catch (FileNotFoundException e) {
            logger.warn(e.getMessage());
        } catch (IOException e) {
            //            e.printStackTrace();
            logger.warn(e.getMessage());
        }
    }
    return null;
}

From source file:com.googlecode.t7mp.steps.resources.CopyUserConfigStep.java

@Override
public void execute(Context context) {
    // setup fields
    this.catalinaBaseDir = context.getMojo().getCatalinaBase();
    this.userConfigDir = context.getMojo().getTomcatConfigDirectory();
    this.log = context.getLog();

    ///* w ww.ja  v a2s  .co m*/
    if (userConfigDir == null) {
        log.info("No directory for userConfigFiles configured.");
        return;
    }
    if (!userConfigDir.exists() || !userConfigDir.isDirectory()) {
        log.warn("The configured Directory for configuration files does not exist. "
                + userConfigDir.getAbsolutePath());
        log.warn("Ignoring user configuration.");
    }
    if (userConfigDir.exists() && userConfigDir.isDirectory()) {
        File[] files = userConfigDir.listFiles(new FilesOnlyFileFilter());
        for (File configFile : files) {
            try {
                if (configFile.getName().equals("catalina.properties")) {
                    mergeUserCatalinaPropertiesWithDefault(configFile);
                    continue;
                }
                log.debug("Copy provided config file '" + configFile.getName() + "' to "
                        + catalinaBaseDir.getAbsolutePath() + "/conf/" + configFile.getName());
                this.setupUtil.copy(new FileInputStream(configFile),
                        new FileOutputStream(new File(catalinaBaseDir, "/conf/" + configFile.getName())));
            } catch (FileNotFoundException e) {
                throw new TomcatSetupException(e.getMessage(), e);
            } catch (IOException e) {
                throw new TomcatSetupException(e.getMessage(), e);
            }
        }
    }
}

From source file:org.kochka.android.weightlogger.tools.SimpleMultipartEntity.java

public void addPart(final String key, final File value) {
    try {//from   w  w  w .  ja  v  a 2  s.c o m
        addPart(key, value.getName(), new FileInputStream(value));
    } catch (final FileNotFoundException e) {
        Log.e("WeightLogger :: ", e.getMessage(), e);
    }
}