java.io.FileNotFoundException.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(12.0k)|赞(0)|评价(0)|浏览(191)

本文整理了Java中java.io.FileNotFoundException.getMessage()方法的一些代码示例,展示了FileNotFoundException.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileNotFoundException.getMessage()方法的具体详情如下:
包路径:java.io.FileNotFoundException
类名称:FileNotFoundException
方法名:getMessage

FileNotFoundException.getMessage介绍

暂无

代码示例

代码示例来源:origin: javax.xml.bind/jaxb-api

public final Object unmarshal( File f ) throws JAXBException {
  if( f == null ) {
    throw new IllegalArgumentException(
      Messages.format( Messages.MUST_NOT_BE_NULL, "file" ) );
  }
  try {
    return unmarshal(new BufferedInputStream(new FileInputStream(f)));
  } catch( FileNotFoundException e ) {
    throw new IllegalArgumentException(e.getMessage());
  }
}

代码示例来源:origin: redwarp/9-Patch-Resizer

public static void copyfile(File input, File output) {
    try {
      InputStream in = new FileInputStream(input);
      OutputStream out = new FileOutputStream(output);

      byte[] buf = new byte[1024];
      int len;
      while ((len = in.read(buf)) > 0) {
        out.write(buf, 0, len);
      }
      in.close();
      out.close();
    } catch (FileNotFoundException ex) {
      System.out
          .println(ex.getMessage() + " in the specified directory.");
      System.exit(0);
    } catch (IOException e) {
      System.out.println(e.getMessage());
    }
  }
}

代码示例来源:origin: k9mail/k-9

private void writeCertificateFile() throws CertificateException {
  java.io.OutputStream keyStoreStream = null;
  try {
    keyStoreStream = new java.io.FileOutputStream(keyStoreFile);
    keyStore.store(keyStoreStream, "".toCharArray());
  } catch (FileNotFoundException e) {
    throw new CertificateException("Unable to write KeyStore: "
        + e.getMessage());
  } catch (CertificateException e) {
    throw new CertificateException("Unable to write KeyStore: "
        + e.getMessage());
  } catch (IOException e) {
    throw new CertificateException("Unable to write KeyStore: "
        + e.getMessage());
  } catch (NoSuchAlgorithmException e) {
    throw new CertificateException("Unable to write KeyStore: "
        + e.getMessage());
  } catch (KeyStoreException e) {
    throw new CertificateException("Unable to write KeyStore: "
        + e.getMessage());
  } finally {
    IOUtils.closeQuietly(keyStoreStream);
  }
}

代码示例来源:origin: apache/geode

static File mergeLogFile(String dirName) throws Exception {
 Path dir = Paths.get(dirName);
 List<File> logsToMerge = findLogFilesToMerge(dir.toFile());
 Map<String, InputStream> logFiles = new HashMap<>();
 for (int i = 0; i < logsToMerge.size(); i++) {
  try {
   logFiles.put(dir.relativize(logsToMerge.get(i).toPath()).toString(),
     new FileInputStream(logsToMerge.get(i)));
  } catch (FileNotFoundException e) {
   throw new Exception(
     logsToMerge.get(i) + " " + CliStrings.EXPORT_LOGS__MSG__FILE_DOES_NOT_EXIST);
  }
 }
 PrintWriter mergedLog = null;
 File mergedLogFile = null;
 try {
  String mergeLog = dirName + File.separator + "merge_"
    + new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new java.util.Date()) + ".log";
  mergedLogFile = new File(mergeLog);
  mergedLog = new PrintWriter(mergedLogFile);
  MergeLogFiles.mergeLogFiles(logFiles, mergedLog);
 } catch (FileNotFoundException e) {
  throw new Exception(
    "FileNotFoundException in creating PrintWriter in MergeLogFiles" + e.getMessage());
 } catch (Exception e) {
  throw new Exception("Exception in creating PrintWriter in MergeLogFiles" + e.getMessage());
 }
 return mergedLogFile;
}

代码示例来源:origin: apache/ignite

/**
 * Print formatted result to given printer. If exceptions presented exception messages will be written to log file.
 *
 * @param printer Consumer for handle formatted result.
 * @return Path to log file if exceptions presented and {@code null} otherwise.
 */
public @Nullable String print(Consumer<String> printer) {
  print(printer, false);
  if (!F.isEmpty(exceptions)) {
    File f = new File(IDLE_VERIFY_FILE_PREFIX + LocalDateTime.now().format(TIME_FORMATTER) + ".txt");
    try (PrintWriter pw = new PrintWriter(f)) {
      print(pw::write, true);
      pw.flush();
      printer.accept("See log for additional information. " + f.getAbsolutePath() + "\n");
      return f.getAbsolutePath();
    }
    catch (FileNotFoundException e) {
      printer.accept("Can't write exceptions to file " + f.getAbsolutePath() + " " + e.getMessage() + "\n");
      e.printStackTrace();
    }
  }
  return null;
}

代码示例来源:origin: TommyLemon/APIJSON

File dir = new File(path);
if (!dir.exists()) {
  dir.mkdirs();
File photoFile = new File(path, photoName + "." + formSuffix); // 在指定路径下创建文件
FileOutputStream fileOutputStream = null;
try {
  Log.e(TAG, "savePhotoToSDCard catch (FileNotFoundException e) {\n " + e.getMessage());
  photoFile.delete();
  Log.e(TAG, "savePhotoToSDCard catch (IOException e) {\n " + e.getMessage());
  photoFile.delete();
    Log.e(TAG, "savePhotoToSDCard } catch (IOException e) {\n " + e.getMessage());

代码示例来源:origin: Javen205/IJPay

if (StringUtils.isNotBlank(rootPath)) {
  LogUtil.writeLog("从路径读取配置文件: " + rootPath+File.separator+FILE_NAME);
  File file = new File(rootPath + File.separator + FILE_NAME);
  InputStream in = null;
  if (file.exists()) {
    try {
      in = new FileInputStream(file);
      properties = new Properties();
      properties.load(in);
      loadProperties(properties);
    } catch (FileNotFoundException e) {
      LogUtil.writeErrorLog(e.getMessage(), e);
    } catch (IOException e) {
      LogUtil.writeErrorLog(e.getMessage(), e);
    } finally {
      if (null != in) {
          in.close();
        } catch (IOException e) {
          LogUtil.writeErrorLog(e.getMessage(), e);

代码示例来源:origin: termux/termux-app

File file = new File(path);
try {
  FileInputStream in = new FileInputStream(file);
  promptNameAndSave(in, file.getName());
} catch (FileNotFoundException e) {
  showErrorDialogAndQuit("Cannot open file: " + e.getMessage() + ".");

代码示例来源:origin: apache/flink

@Override
  public boolean accept(File dir, String name) {
    if (fileName != null && !name.equals(fileName)) {
      return false;
    }
    File f = new File(dir.getAbsolutePath() + "/" + name);
    LOG.info("Searching in {}", f.getAbsolutePath());
    try {
      Set<String> foundSet = new HashSet<>(mustHave.length);
      Scanner scanner = new Scanner(f);
      while (scanner.hasNextLine()) {
        final String lineFromFile = scanner.nextLine();
        for (String str : mustHave) {
          if (lineFromFile.contains(str)) {
            foundSet.add(str);
          }
        }
        if (foundSet.containsAll(mustHaveList)) {
          return true;
        }
      }
    } catch (FileNotFoundException e) {
      LOG.warn("Unable to locate file: " + e.getMessage() + " file: " + f.getAbsolutePath());
    }
    return false;
  }
});

代码示例来源:origin: TommyLemon/Android-ZBLibrary

File dir = new File(path);
if (!dir.exists()) {
  dir.mkdirs();
File photoFile = new File(path, photoName + "." + formSuffix); // 在指定路径下创建文件
FileOutputStream fileOutputStream = null;
try {
  Log.e(TAG, "savePhotoToSDCard catch (FileNotFoundException e) {\n " + e.getMessage());
  photoFile.delete();
  Log.e(TAG, "savePhotoToSDCard catch (IOException e) {\n " + e.getMessage());
  photoFile.delete();
    Log.e(TAG, "savePhotoToSDCard } catch (IOException e) {\n " + e.getMessage());

代码示例来源:origin: aws/aws-sdk-java

/**
 * Asserts that the contents in the specified file are exactly equal to the contents read from
 * the specified input stream. The input stream will be closed at the end of this method. If any
 * problems are encountered, or the stream's contents don't match up exactly with the file's
 * contents, then this method will fail the current test.
 *
 * @param errmsg
 *            error message to be thrown when the assertion fails.
 * @param expected
 *            The file containing the expected contents.
 * @param actual
 *            The stream that will be read, compared to the expected file contents, and finally
 *            closed.
 */
public static void assertFileEqualsStream(String errmsg, File expected, InputStream actual) {
  try {
    InputStream expectedInputStream = new FileInputStream(expected);
    assertStreamEqualsStream(errmsg, expectedInputStream, actual);
  } catch (FileNotFoundException e) {
    fail("Expected file " + expected.getAbsolutePath() + " doesn't exist: " + e.getMessage());
  }
}

代码示例来源:origin: javaee/glassfish

if (!("PKCS11".equalsIgnoreCase(type) ||
    "".equalsIgnoreCase(path))) {
    File keyStoreFile = new File(path);
    if (!keyStoreFile.isAbsolute()) {
      keyStoreFile = new File(System.getProperty("catalina.base"),
        path);
    istream = new FileInputStream(keyStoreFile);
  logger.log(Level.SEVERE, sm.getString("jsse.keystore_load_failed", type, path, fnfe.getMessage()), fnfe);
  throw fnfe;
} catch (IOException ioe) {
  logger.log(Level.SEVERE, sm.getString("jsse.keystore_load_failed", type, path, ioe.getMessage()), ioe);
  throw ioe;
} catch (Exception ex) {

代码示例来源:origin: oracle/opengrok

} catch (java.io.FileNotFoundException e) {
  LOGGER.log(Level.WARNING, "failed to find file: {0}",
      e.getMessage());
} catch (java.io.IOException e) {
  LOGGER.log(Level.WARNING, "failed to read file: {0}",
      e.getMessage());
} finally {
  if (input != null) {

代码示例来源:origin: apache/cloudstack

@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
  File configFile = PropertiesUtil.findConfigFile(configuration);
  FileInputStream inputFile = null;
  try {
    if (null == configFile) {
      throw new FileNotFoundException("Configuration file was not found!");
    }
    inputFile = new FileInputStream(configFile);
  } catch (FileNotFoundException e) {
    s_logger.error(e.getMessage());
    throw new ConfigurationException(e.getMessage());
  }
  final Properties configProps = new Properties();
  try {
    configProps.load(inputFile);
  } catch (IOException e) {
    s_logger.error(e.getMessage());
    throw new ConfigurationException(e.getMessage());
  } finally {
    closeAutoCloseable(inputFile, "error closing config file");
  }
  _mgmtCidr = configProps.getProperty("management.cidr");
  _mgmtGateway = configProps.getProperty("management.gateway");
  s_logger.info("Management network " + _mgmtCidr + " gateway: " + _mgmtGateway);
  return true;
}

代码示例来源:origin: jeremylong/DependencyCheck

fis = new FileInputStream(archive);
} catch (FileNotFoundException ex) {
  final String msg = String.format("Error extracting file `%s`: %s", archive.getAbsolutePath(), ex.getMessage());
  LOGGER.debug(msg, ex);
  throw new AnalysisException(msg);
  } else if ("gz".equals(archiveExt) || "tgz".equals(archiveExt)) {
    final String uncompressedName = GzipUtils.getUncompressedFilename(archive.getName());
    final File f = new File(destination, uncompressedName);
    if (engine.accept(f)) {
      final String destPath = destination.getCanonicalPath();
    final File f = new File(destination, uncompressedName);
    if (engine.accept(f)) {
      final String destPath = destination.getCanonicalPath();

代码示例来源:origin: apache/flink

@Override
public boolean accept(File dir, String name) {
File f = new File(dir.getAbsolutePath() + "/" + name);
try {
  BufferingScanner scanner = new BufferingScanner(new Scanner(f), 10);
  LOG.warn("Unable to locate file: " + e.getMessage() + " file: " + f.getAbsolutePath());

代码示例来源:origin: awsdocs/aws-doc-sdk-examples

S3Object o = s3.getObject(bucket_name, key_name);
  S3ObjectInputStream s3is = o.getObjectContent();
  FileOutputStream fos = new FileOutputStream(new File(key_name));
  byte[] read_buf = new byte[1024];
  int read_len = 0;
  System.exit(1);
} catch (FileNotFoundException e) {
  System.err.println(e.getMessage());
  System.exit(1);
} catch (IOException e) {
  System.err.println(e.getMessage());
  System.exit(1);

代码示例来源:origin: Dreampie/Resty

/**
 * Prop constructor
 * <p/>
 * Example:<br>
 * Prop prop = new Prop(new File("/var/config/my_config.txt"), "UTF-8");<br>
 * String userName = prop.getMessage("userName");
 *
 * @param file     the properties File object
 * @param encoding the encoding
 */
public Prop(File file, String encoding) {
 if (file == null)
  throw new IllegalArgumentException("File can not be null.");
 String fileName = file.getName();
 if (!file.isFile())
  throw new IllegalArgumentException("Not a file : " + fileName);
 InputStream inputStream;
 try {
  inputStream = new FileInputStream(file);
  load(fileName, inputStream, encoding);
 } catch (FileNotFoundException e) {
  logger.warn(e.getMessage(), e);
 }
}

代码示例来源:origin: TommyLemon/APIJSON

} catch (FileNotFoundException e) {
  Log.e(TAG, "storeFile  try { FileInputStream in = new FileInputStream(file); ... >>" +
      " } catch (FileNotFoundException e) {\n" + e.getMessage() + "\n\n >> path = null;");
  path = null;
} catch (IOException e) {
  Log.e(TAG, "storeFile  try { FileInputStream in = new FileInputStream(file); ... >>" +
      " } catch (IOException e) {\n" + e.getMessage() + "\n\n >> path = null;");
  path = null;

代码示例来源:origin: apache/cloudstack

try(FileInputStream db_prop_fstream = new FileInputStream(dbPropsFile);) {
  dbProps.load(db_prop_fstream);
  backupDBProps = new PropertiesConfiguration(dbPropsFile);
} catch (FileNotFoundException e) {
  System.out.println("db.properties file not found while reading DB secret key" + e.getMessage());
} catch (IOException e) {
  System.out.println("Error while reading DB secret key from db.properties" + e.getMessage());
} catch (ConfigurationException e) {
  e.printStackTrace();

相关文章