/** * Constructor. Loads the constants needed for computations. They are exactly like the ones the blender uses. Each * deriving class should override this method and load its own constraints. */ public NoiseGenerator() { LOGGER.fine("Loading noise constants."); InputStream is = NoiseGenerator.class.getResourceAsStream("noiseconstants.dat"); try { ObjectInputStream ois = new ObjectInputStream(is); hashpntf = (float[]) ois.readObject(); hash = (short[]) ois.readObject(); hashvectf = (float[]) ois.readObject(); p = (short[]) ois.readObject(); g = (float[][]) ois.readObject(); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } catch (ClassNotFoundException e) { assert false : "Constants' classes should be arrays of primitive types, so they are ALWAYS known!"; } finally { if (is != null) { try { is.close(); } catch (IOException e) { LOGGER.log(Level.WARNING, e.getLocalizedMessage()); } } } }
private void doExportTree() { JFileChooser chooser = new JFileChooser(); chooser.setSelectedFile(new File("./tree.png")); FileNameExtensionFilter filter = new FileNameExtensionFilter("PNG images", "png"); chooser.setFileFilter(filter); int status = chooser.showSaveDialog(this); if (status != JFileChooser.APPROVE_OPTION) return; Dimension size = tjp.getPreferredSize(); BufferedImage im = new BufferedImage((int) size.getWidth(), (int) size.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g = im.createGraphics(); tjp.paint(g); try { ImageIO.write(im, "png", chooser.getSelectedFile()); } catch (IOException e) { JOptionPane.showMessageDialog(this, "Failed to save the tree image file.\n" + e.getLocalizedMessage(), "Export Error", JOptionPane.ERROR_MESSAGE); } }
LOGGER.log( Level.WARNING, "Unable to test with this resource name: " LOGGER.log( Level.WARNING, "Unable to test with this resource name which does not has properties."); try { properties = new File(testData.getDataDirectoryRoot(), ManifestLoader.PROPERTIES_FILE); writer.flush(); } catch (IOException e) { LOGGER.log( Level.WARNING, "Unable to write test data to:" + testData.getDataDirectoryRoot()); org.junit.Assert.fail(e.getLocalizedMessage()); } finally { IOUtils.closeQuietly(writer);
public static void createFormatFile(File adminDir) throws SVNException { OutputStream os = null; try { os = SVNFileUtil.openFileForWriting(new File(adminDir, "format")); os.write(FORMAT_TEXT); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage()); SVNErrorManager.error(err, e, SVNLogType.FSFS); } finally { SVNFileUtil.closeFile(os); } }
WorldImageReader.class.toString(), "WorldImageReader", ex.getLocalizedMessage(), ex); throw new DataSourceException(ex); path = "//" + auth + path; this.source = input = new File(URLDecoder.decode(path, "UTF-8")); } else if (sourceURL.getProtocol().equalsIgnoreCase("http")) { if (tempCRS != null) { this.crs = (CoordinateReferenceSystem) tempCRS; LOGGER.log(Level.WARNING, "Using forced coordinate reference system "); } else readCRS(); LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); throw new DataSourceException(e); } catch (TransformException e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); throw new DataSourceException(e);
private void writeDumpData(OutputStream out, byte[] bytes) throws SVNException { try { out.write(bytes); } catch (IOException ioe) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, ioe.getLocalizedMessage()); SVNErrorManager.error(err, ioe, SVNLogType.FSFS); } }
@Override public void save(BackupMetadata backupMetadata) { File snapshotFile = new File(filename); if (!snapshotFile.exists()) snapshotFile.getParentFile().mkdirs(); // Will save entire list to file. try (final ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(filename))) { out.writeObject(backupMetadataMap); out.flush(); logger.info( "Snapshot status of size {} is saved to {}", backupMetadataMap.size(), filename); } catch (IOException e) { logger.error( "Error while trying to persist snapshot status to {}. Error: {}", filename, e.getLocalizedMessage()); } }
/** * Write the provided {@link RenderedImage} in the debug directory with the provided file name. * * @param raster the {@link RenderedImage} that we have to write. * @param fileName a {@link String} indicating where we should write it. */ static void writeRenderedImage(final RenderedImage raster, final String fileName) { if (DUMP_DIRECTORY == null) throw new NullPointerException( "Unable to write the provided coverage in the debug directory"); if (DEBUG == false) throw new IllegalStateException( "Unable to write the provided coverage since we are not in debug mode"); try { ImageIO.write(raster, "tiff", new File(DUMP_DIRECTORY, fileName + ".tiff")); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } }
public static void createFormatFile(File adminDir) throws SVNException { OutputStream os = null; try { os = SVNFileUtil.openFileForWriting(new File(adminDir, "format")); os.write(FORMAT_TEXT); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage()); SVNErrorManager.error(err, e, SVNLogType.FSFS); } finally { SVNFileUtil.closeFile(os); } }
LOGGER.log( java.util.logging.Level.SEVERE, "Error loading resources file: " + e.getLocalizedMessage(), e); } finally { LOGGER.log( java.util.logging.Level.SEVERE, "Error loading resources file: " + e.getLocalizedMessage(), e);
private void writeDumpData(OutputStream out, byte[] bytes) throws SVNException { try { out.write(bytes); } catch (IOException ioe) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, ioe.getLocalizedMessage()); SVNErrorManager.error(err, ioe, SVNLogType.FSFS); } }
private void init() { File snapshotFile = new File(filename); if (!snapshotFile.exists()) { snapshotFile.getParentFile().mkdirs(); "Error while trying to fetch snapshot status from {}. Error: {}. If this is first time after upgrading Priam, ignore this.", filename, e.getLocalizedMessage()); e.printStackTrace(); } catch (Exception e) {
final File prjFile = new File(prjPath); if (prjFile.exists()) { LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); } catch (IOException e) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); LOGGER.log(FINE, ioe.getLocalizedMessage(), ioe);
public static void createFormatFile(File adminDir) throws SVNException { OutputStream os = null; try { os = SVNFileUtil.openFileForWriting(new File(adminDir, "format")); os.write(FORMAT_TEXT); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage()); SVNErrorManager.error(err, e, SVNLogType.FSFS); } finally { SVNFileUtil.closeFile(os); } }
protected void createData(String name) throws IOException { File f = getFile(name); boolean isError = true; IOException creationException = null; String annotationMsg = null; try { isError = f.createNewFile() ? false : true; isError = isError ? true : (!f.exists()); if (isError) { annotationMsg = NbBundle.getMessage(LocalFileSystem.class, "EXC_DataAlreadyExist", f.getName(), getDisplayName(), f.getAbsolutePath()); creationException = new SyncFailedException(annotationMsg); } } catch (IOException iex) { isError = true; creationException = iex; annotationMsg = iex.getLocalizedMessage(); } if (isError) { LOG.log(Level.INFO, "Trying to create new file {0}.", f.getPath()); ExternalUtil.annotate(creationException, annotationMsg); throw creationException; } }
private void writeDumpData(OutputStream out, byte[] bytes) throws SVNException { try { out.write(bytes); } catch (IOException ioe) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, ioe.getLocalizedMessage()); SVNErrorManager.error(err, ioe, SVNLogType.FSFS); } }
/** * Utility method to write to a file. * Throws the exception, so we can report it in syncing log */ private static void writeToFileImpl(InputStream source, String destination) throws IOException { File f = new File(destination); try { Timber.d("Creating new file... = %s", destination); f.createNewFile(); long startTimeMillis = System.currentTimeMillis(); long sizeBytes = CompatHelper.getCompat().copyFile(source, destination); long endTimeMillis = System.currentTimeMillis(); Timber.d("Finished writeToFile!"); long durationSeconds = (endTimeMillis - startTimeMillis) / 1000; long sizeKb = sizeBytes / 1024; long speedKbSec = 0; if (endTimeMillis != startTimeMillis) { speedKbSec = sizeKb * 1000 / (endTimeMillis - startTimeMillis); } Timber.d("Utils.writeToFile: Size: %d Kb, Duration: %d s, Speed: %d Kb/s", sizeKb, durationSeconds, speedKbSec); } catch (IOException e) { throw new IOException(f.getName() + ": " + e.getLocalizedMessage(), e); } }
final File prjFile = new File(base.toString()); if (prjFile.exists()) { LOGGER.log(Level.INFO, e.getLocalizedMessage(), e); } catch (IOException e) { LOGGER.log(Level.INFO, e.getLocalizedMessage(), e); } catch (FactoryException e) { LOGGER.log(Level.INFO, e.getLocalizedMessage(), e); } finally { if (projReader != null) LOGGER.log(Level.FINE, e.getLocalizedMessage(), e); LOGGER.log(Level.FINE, e.getLocalizedMessage(), e);
public static void createFormatFile(File adminDir) throws SVNException { OutputStream os = null; try { os = SVNFileUtil.openFileForWriting(new File(adminDir, "format")); os.write(FORMAT_TEXT); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage()); SVNErrorManager.error(err, e); } finally { SVNFileUtil.closeFile(os); } }
@Override public AbstractGridCoverage2DReader getReader(Object source, Hints hints) { try { return new MBTilesReader(source, hints); } catch (IOException e) { LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); return null; } }