Example usage for java.io IOException getLocalizedMessage

List of usage examples for java.io IOException getLocalizedMessage

Introduction

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

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:models.monitor.MonitorProvider.java

public DiskUsage getFreeDiskspace() {

    long freeSpace = -1L;
    try {/*w  ww  .  j a  v a  2  s  .  c  o m*/
        freeSpace = FileSystemUtils.freeSpaceKb("/");
    } catch (IOException e) {
        models.utils.LogUtils.printLogError("Error in getFreeDiskspace() " + e.getLocalizedMessage());
        //e.printStackTrace();
    }
    int gb = 1024 * 1024;
    DiskUsage usage = new DiskUsage();
    usage.freeSpaceGb = (double) freeSpace / (double) gb;

    if (VarUtils.IN_DETAIL_DEBUG) {

        models.utils.LogUtils.printLogNormal("Free Space:" + usage.freeSpaceGb + " GB");
    }

    currentDiskUsage = usage;
    return usage;
}

From source file:com.photon.phresco.plugins.xcode.CodeValidation.java

private void createreport() throws MojoExecutionException {
    File outputFile = getReport();
    if (outputFile == null) {
        throw new MojoExecutionException("Report not generated");
    } else {/*  www  .  j a  v  a  2s.c o  m*/
        try {
            String report = "static-analysis-report";
            File baseFolder = new File(baseDir + DO_NOT_CHECKIN, report);
            if (!baseFolder.exists()) {
                baseFolder.mkdirs();
            }
            File destFile = new File(baseFolder, outputFile.getName());
            getLog().info("Destination file " + destFile.getAbsolutePath());
            File[] listFiles = outputFile.listFiles();
            for (File file : listFiles) {
                XcodeUtil.copyFiles(file, baseFolder);
            }
            //            XcodeUtil.copyFolder(outputFile, destFile);

            getLog().info("copied to..." + destFile.getName());
            //appFileName = destFile.getAbsolutePath();

            FileUtils.deleteDirectory(outputFile);
        } catch (IOException e) {
            throw new MojoExecutionException("Error in writing output..." + e.getLocalizedMessage());
        }
    }

}

From source file:com.swordlord.gozer.frame.wicket.BinaryStreamWriter.java

@Override
public void write(OutputStream output) {
    try {/*w  ww  .ja v a2  s .  co  m*/
        _stream.writeTo(output);
    } catch (IOException e) {
        LOG.error(
                MessageFormat.format("Error during write in BinaryStreamWriter: {0}", e.getLocalizedMessage()));
    }
}

From source file:format.OverlapInputFormat.java

/******
    @Override/*ww w  .ja v  a2 s .  c  om*/
    public List<InputSplit> getSplits(JobContext job) throws IOException {
Configuration conf = HadoopUtils.getConfiguration(job);
        
List<InputSplit> defaultSplits = super.getSplits(job);
List<InputSplit> result = new ArrayList<InputSplit>();
        
Path prevFile = null;
FourMcBlockIndex prevIndex = null;
        
for (InputSplit genericSplit : defaultSplits) {
    // Load the index.
    FileSplit fileSplit = (FileSplit) genericSplit;
    Path file = fileSplit.getPath();
    FileSystem fs = file.getFileSystem(conf);
        
    FourMcBlockIndex index;
    if (file.equals(prevFile)) {
        index = prevIndex;
    } else {
        index = FourMcBlockIndex.readIndex(fs, file);
        prevFile = file;
        prevIndex = index;
    }
        
    if (index == null) {
        throw new IOException("BlockIndex unreadable for " + file);
    }
        
    if (index.isEmpty()) { // leave the default split for empty block index
        result.add(fileSplit);
        continue;
    }
        
    long start = fileSplit.getStart();
    long end = start + fileSplit.getLength();
        
    long fourMcStart = index.alignSliceStartToIndex(start, end);
    long fourMcEnd = index.alignSliceEndToIndex(end, fs.getFileStatus(file).getLen());
        
    if (fourMcStart != FourMcBlockIndex.NOT_FOUND && fourMcEnd != FourMcBlockIndex.NOT_FOUND) {
        result.add(new FileSplit(file, fourMcStart, fourMcEnd - fourMcStart, fileSplit.getLocations()));
        LOG.debug("Added 4mc split for " + file + "[start=" + fourMcStart + ", length=" + (fourMcEnd - fourMcStart) + "]");
    }
        
}
        
return result;
    }
 ******/

@Override
public List<InputSplit> getSplits(JobContext context) {
    List<InputSplit> splits = new ArrayList<InputSplit>();
    FileSystem fs = null;
    Path file = OverlapInputFormat.getInputPaths(context)[0];
    Configuration conf = context.getConfiguration();
    long blocksize = Long.parseLong(conf.get("dfs.blocksize"));
    //        long overlap = Long.parseLong(conf.get("pcap.defaultsize"));
    long overlap = 16;
    FSDataInputStream in = null;
    try {
        fs = FileSystem.get(context.getConfiguration());
        in = fs.open(file);
        long pos = 0;
        while (in.available() > 0) {
            FileSplit split = new FileSplit(file, pos, blocksize + overlap, new String[] {});
            splits.add(split);
            pos += blocksize;
            in.skip(blocksize + overlap);
        }
    } catch (IOException e) {
        LOG.error(e.getLocalizedMessage());
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (Exception e) {
            }
        }
        ;
        if (fs != null) {
            try {
                fs.close();
            } catch (Exception e) {
            }
        }
        ;
    }
    return splits;
}

From source file:com.tridion.storage.si4t.dao.JPASearchPageDAO.java

public void create(CharacterData page, String relativePath) throws StorageException {
    log.debug("Create.");
    TridionPublishableItemProcessor tp;//  w  ww.  ja  v  a2s.c o m
    try {
        tp = new TridionPublishableItemProcessor(page.getString(), FactoryAction.UPDATE, IndexType.PAGE,
                Integer.toString(page.getPublicationId()),
                "tcm:" + page.getPublicationId() + "-" + page.getId() + "-64", this.storageId);
        CharacterData c = tp.processPageSource(page);
        if (c != null) {
            super.create(c, relativePath);
        } else {
            log.error(
                    "Error processing page: " + relativePath + ", proceeding with deployment of original page");
            super.create(page, relativePath);
        }
    } catch (IOException e) {
        log.error(Utils.stacktraceToString(e.getStackTrace()));
        throw new StorageException("IO Exception: " + e.getLocalizedMessage(), e);
    }
}

From source file:jenkins.plugins.publish_over_ftp.BapFtpClient.java

public void disconnect() {
    if ((ftpClient != null) && ftpClient.isConnected()) {
        try {//from   w w  w .  j  a v  a  2 s .  c  o m
            ftpClient.disconnect();
        } catch (IOException ioe) {
            throw new BapPublisherException(Messages.exception_exceptionOnDisconnect(ioe.getLocalizedMessage()),
                    ioe);
        }
    }
}

From source file:io.v.positioning.gae.ServletPostAsyncTask.java

@Override
protected String doInBackground(Context... params) {
    mContext = params[0];/*www .j a v  a2 s .c  o m*/
    DataOutputStream os = null;
    InputStream is = null;
    try {
        URLConnection conn = mUrl.openConnection();
        conn.setDoOutput(true);
        conn.setDoInput(true);
        conn.setUseCaches(false);
        conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
        conn.connect();
        os = new DataOutputStream(conn.getOutputStream());
        os.write(mData.toString().getBytes("UTF-8"));
        is = conn.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        return br.readLine();
    } catch (IOException e) {
        return "IOException while contacting GEA: " + e.getMessage();
    } catch (Exception e) {
        return "Exception while contacting GEA: " + e.getLocalizedMessage();
    } finally {
        if (os != null)
            try {
                os.close();
            } catch (IOException e) {
                return "IOException closing os: " + e.getMessage();
            }
        if (is != null)
            try {
                is.close();
            } catch (IOException e) {
                return "IOException closing is: " + e.getMessage();
            }
    }
}

From source file:co.cask.hydrator.transforms.ParseCSV.java

@Override
public void transform(StructuredRecord in, Emitter<StructuredRecord> emitter) throws Exception {
    // Field has to string to be parsed correctly. For others throw an exception.
    String body = in.get(config.field);

    // Parse the text as CSV and emit it as structured record.
    try {//from   ww w  .  j  a  v a 2s  . c o m
        CSVParser parser = CSVParser.parse(body, csvFormat);
        List<CSVRecord> records = parser.getRecords();
        for (CSVRecord record : records) {
            if (fields.size() == record.size()) {
                StructuredRecord sRecord = createStructuredRecord(record);
                emitter.emit(sRecord);
            } else {
                LOG.warn("Skipping record as ouput schema specified has '{}' fields, while CSV record has '{}'",
                        fields.size(), record.size());
                // Write the record to error Dataset.
            }
        }
    } catch (IOException e) {
        LOG.error("There was a issue parsing the record. ", e.getLocalizedMessage());
    }
}

From source file:com.tridion.storage.si4t.dao.JPASearchPageDAO.java

@Override
public void update(CharacterData page, String originalRelativePath, String newRelativePath)
        throws StorageException {
    log.debug("Update. Orgpath=" + originalRelativePath);

    TridionPublishableItemProcessor tp;/* w w w  . j  a  v a  2 s  .  c o  m*/
    try {
        tp = new TridionPublishableItemProcessor(page.getString(), FactoryAction.UPDATE, IndexType.PAGE,
                Integer.toString(page.getPublicationId()),
                "tcm:" + page.getPublicationId() + "-" + page.getId() + "-64", this.storageId);
        CharacterData c = tp.processPageSource(page);
        if (c != null) {
            super.update(c, originalRelativePath, newRelativePath);
        } else {
            log.error("Error processing page: " + newRelativePath
                    + ", proceeding with deployment of original page");
            super.update(page, originalRelativePath, newRelativePath);
        }
    } catch (IOException e) {
        log.error(Utils.stacktraceToString(e.getStackTrace()));
        throw new StorageException("IO Exception: " + e.getLocalizedMessage(), e);
    }
}

From source file:com.orange.mmp.mvc.actions.CertifAction.java

public String input() throws Exception {
    if (getUploadedFile() == null) {
        addActionError(getText("error.certif.upload",
                new String[] { getText("error.certif.nofile", new String[] {}) }));
        return this.execute();
    }/*from  w w w  .j  ava 2s. com*/

    if (!getUploadedFileContentType().equals(Constants.MIMETYPE_CERTIF)) {
        addActionError(getText("error.certif.upload",
                new String[] { getText("error.certif.format", new String[] {}) }));
        return this.execute();
    }

    File dstFile = new File(MidletManager.getInstance().getKeystoreFile());
    // Try to create file
    InputStream input = new FileInputStream(getUploadedFile());
    OutputStream output = new FileOutputStream(dstFile);
    try {
        IOUtils.copy(input, output);
        addActionMessage(getText("message.certif.upload", new String[] {}));
    } catch (IOException ioe) {
        addActionError(getText("error.certif.upload", new String[] { ioe.getLocalizedMessage() }));
    } finally {
        input.close();
        output.close();
    }

    return this.execute();
}