當前位置: 首頁>>代碼示例>>Java>>正文


Java FileNotFoundException類代碼示例

本文整理匯總了Java中java.io.FileNotFoundException的典型用法代碼示例。如果您正苦於以下問題:Java FileNotFoundException類的具體用法?Java FileNotFoundException怎麽用?Java FileNotFoundException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FileNotFoundException類屬於java.io包,在下文中一共展示了FileNotFoundException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getJarFile

import java.io.FileNotFoundException; //導入依賴的package包/類
private JarFile getJarFile(URL url) throws IOException {
    // Optimize case where url refers to a local jar file
    if (isOptimizable(url)) {
        //HACK
        //FileURLMapper p = new FileURLMapper (url);
        File p = new File(url.getPath());

        if (!p.exists()) {
            throw new FileNotFoundException(p.getPath());
        }
        return new JarFile (p.getPath());
    }
    URLConnection uc = getBaseURL().openConnection();
    uc.setRequestProperty(USER_AGENT_JAVA_VERSION, JAVA_VERSION);
    return ((JarURLConnection)uc).getJarFile();
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:17,代碼來源:URLClassPath.java

示例2: getDiskStoreIdFromInitFile

import java.io.FileNotFoundException; //導入依賴的package包/類
private String getDiskStoreIdFromInitFile(File dir, String fileName)
    throws FileNotFoundException, IOException {
  FileInputStream fis = new FileInputStream(new File(dir, fileName));
  try {
    byte[] bytes = new byte[1 + 8 + 8];
    fis.read(bytes);
    ByteBuffer buffer = ByteBuffer.wrap(bytes);
    // Skip the record type.
    buffer.get();
    long least = buffer.getLong();
    long most = buffer.getLong();
    UUID id = new UUID(most, least);
    return id.toString();
  } finally {
    fis.close();
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:18,代碼來源:HydraLineMapper.java

示例3: renameDocument

import java.io.FileNotFoundException; //導入依賴的package包/類
@Override
public String renameDocument(String documentId, String displayName) throws FileNotFoundException {
    // Since this provider treats renames as generating a completely new
    // docId, we're okay with letting the MIME type change.
    displayName = FileUtils.buildValidFatFilename(displayName);

    final RootFile before = getRootFileForDocId(documentId);
    final RootFile after = new RootFile(before.getParent(), displayName);

    if(!RootCommands.renameRootTarget(before, after)){
        throw new IllegalStateException("Failed to rename " + before);
    }
    final String afterDocId = getDocIdForRootFile(new RootFile(after.getParent(), displayName));
    if (!TextUtils.equals(documentId, afterDocId)) {
        notifyDocumentsChanged(documentId);
        return afterDocId;
    } else {
        return null;
    }
}
 
開發者ID:gigabytedevelopers,項目名稱:FireFiles,代碼行數:21,代碼來源:RootedStorageProvider.java

示例4: deleteUnnecessaryFakeDirectories

import java.io.FileNotFoundException; //導入依賴的package包/類
private void deleteUnnecessaryFakeDirectories(Path f) throws IOException {
  while (true) {
    try {
      String key = pathToKey(f);
      if (key.isEmpty()) {
        break;
      }

      S3AFileStatus status = getFileStatus(f);

      if (status.isDirectory() && status.isEmptyDirectory()) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Deleting fake directory " + key + "/");
        }
        s3.deleteObject(bucket, key + "/");
        statistics.incrementWriteOps(1);
      }
    } catch (FileNotFoundException | AmazonServiceException e) {
    }

    if (f.isRoot()) {
      break;
    }

    f = f.getParent();
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:28,代碼來源:S3AFileSystem.java

示例5: execution

import java.io.FileNotFoundException; //導入依賴的package包/類
@Override
protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) {
    File fileToBeModified = getAbsoluteFile(transformedAppFolder, transformationContext);

    if (!fileToBeModified.exists()) {
        // TODO Should this be done as pre-validation?
        FileNotFoundException ex = new FileNotFoundException("File to be modified has not been found");
        return TOExecutionResult.error(this, ex);
    }

    TOExecutionResult result = null;

    try {
        FileUtils.fileAppend(fileToBeModified.getAbsolutePath(), EolHelper.findEolDefaultToOs(fileToBeModified));
        FileUtils.fileAppend(fileToBeModified.getAbsolutePath(), newLine);
        String details =  "A new line has been added to file " + getRelativePath(transformedAppFolder, fileToBeModified);
        result = TOExecutionResult.success(this, details);
    } catch (IOException e) {
        result = TOExecutionResult.error(this, e);
    }

    return result;
}
 
開發者ID:paypal,項目名稱:butterfly,代碼行數:24,代碼來源:AddLine.java

示例6: createDoc

import java.io.FileNotFoundException; //導入依賴的package包/類
public void createDoc() throws FileNotFoundException{
	 /** 創建Document對象(word文檔)  */
       Rectangle rectPageSize = new Rectangle(PageSize.A4);
       rectPageSize = rectPageSize.rotate();
       // 創建word文檔,並設置紙張的大小
       doc = new Document(PageSize.A4);
       file=new File(path+docFileName);
       fileOutputStream=new FileOutputStream(file);
       /** 建立一個書寫器與document對象關聯,通過書寫器可以將文檔寫入到輸出流中 */
       RtfWriter2.getInstance(doc, fileOutputStream );
       doc.open();
       //設置頁邊距,上、下25.4毫米,即為72f,左、右31.8毫米,即為90f  
       doc.setMargins(90f, 90f, 72f, 72f);
       //設置標題字體樣式,粗體、二號、華文中宋  
       tfont  = DocStyleUtils.setFontStyle("華文中宋", 22f, Font.BOLD);  
       //設置正文內容的字體樣式,常規、三號、仿宋_GB2312  
       bfont = DocStyleUtils.setFontStyle("仿宋_GB2312", 16f, Font.NORMAL);
}
 
開發者ID:wkeyuan,項目名稱:DWSurvey,代碼行數:19,代碼來源:DocExportUtil.java

示例7: loadConfig

import java.io.FileNotFoundException; //導入依賴的package包/類
/**
 * Attempts to load properties file with database configuration. Must
 * include username, password, database, and hostname.
 *
 * @param configPath path to database properties file
 * @return database properties
 * @throws IOException if unable to properly parse properties file
 * @throws FileNotFoundException if properties file not found
 */
private Properties loadConfig(String configPath) throws FileNotFoundException, IOException {

	// Specify which keys must be in properties file
	Set<String> required = new HashSet<>();
	required.add("username");
	required.add("password");
	required.add("database");
	required.add("hostname");

	// Load properties file
	Properties config = new Properties();
	config.load(new FileReader(configPath));

	// Check that required keys are present
	if (!config.keySet().containsAll(required)) {
		String error = "Must provide the following in properties file: ";
		throw new InvalidPropertiesFormatException(error + required);
	}

	return config;
}
 
開發者ID:brianisadog,項目名稱:hotelApp,代碼行數:31,代碼來源:DatabaseConnector.java

示例8: save

import java.io.FileNotFoundException; //導入依賴的package包/類
/**
 * Save the cached profiles to disk
 */
public void save()
{
    String s = this.gson.toJson((Object)this.getEntriesWithLimit(1000));
    BufferedWriter bufferedwriter = null;

    try
    {
        bufferedwriter = Files.newWriter(this.usercacheFile, Charsets.UTF_8);
        bufferedwriter.write(s);
        return;
    }
    catch (FileNotFoundException var8)
    {
        ;
    }
    catch (IOException var9)
    {
        return;
    }
    finally
    {
        IOUtils.closeQuietly((Writer)bufferedwriter);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:28,代碼來源:PlayerProfileCache.java

示例9: testInventoryModule

import java.io.FileNotFoundException; //導入依賴的package包/類
@Test
public void testInventoryModule() throws FileNotFoundException {
  Path modulesFolder = Paths.get("src/test/resources/generic");
  Path modulePath = modulesFolder.resolve("example_module.json");
  
  JsonReader reader = new JsonReader(new FileReader(modulePath.toString()));
  JsonObject module = new JsonParser().parse(reader).getAsJsonObject();
  
  // example_module has 4 codes:
  // Examplitis condition
  // Examplitol medication
  // Examplotomy_Encounter
  // Examplotomy procedure
  
  
  Concepts.inventoryModule(concepts, module);
  
  assertEquals(4, concepts.cellSet().size());
  assertEquals("Examplitis", concepts.get("SNOMED-CT", "123"));
  assertEquals("Examplitol", concepts.get("RxNorm", "456"));
  assertEquals("Examplotomy Encounter", concepts.get("SNOMED-CT", "ABC"));
  assertEquals("Examplotomy", concepts.get("SNOMED-CT", "789"));
}
 
開發者ID:synthetichealth,項目名稱:synthea_java,代碼行數:24,代碼來源:ConceptsTest.java

示例10: openLog

import java.io.FileNotFoundException; //導入依賴的package包/類
void openLog(final String loggingFolder) {
    try {
        filename = loggingFolder + "/ProcessingTime_" + filterClassName
                + DATE_FORMAT.format(new Date()) + ".txt";
        logStream = new PrintStream(new BufferedOutputStream(
                new FileOutputStream(new File(filename))));
        log.log(Level.INFO, "Created motion flow logging file with "
                + "processing time statistics at {0}", filename);
        logStream.println("Processing time statistics of motion flow "
                + "calculation, averaged over event packets.");
        logStream.println("Date: " + new Date());
        logStream.println("Filter used: " + filterClassName);
        logStream.println();
        logStream.println("timestamp [us] | processing time [us]");
    } catch (FileNotFoundException ex) {
        log.log(Level.SEVERE, null, ex);
    }
}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:19,代碼來源:MotionFlowStatistics.java

示例11: addNewConfigResource

import java.io.FileNotFoundException; //導入依賴的package包/類
private void addNewConfigResource(String rsrcName, String keyGroup,
    String groups, String keyHosts, String hosts)
        throws FileNotFoundException, UnsupportedEncodingException {
  // location for temp resource should be in CLASSPATH
  Configuration conf = new Configuration();
  URL url = conf.getResource("hdfs-site.xml");

  String urlPath = URLDecoder.decode(url.getPath().toString(), "UTF-8");
  Path p = new Path(urlPath);
  Path dir = p.getParent();
  tempResource = dir.toString() + "/" + rsrcName;

  String newResource =
  "<configuration>"+
  "<property><name>" + keyGroup + "</name><value>"+groups+"</value></property>" +
  "<property><name>" + keyHosts + "</name><value>"+hosts+"</value></property>" +
  "</configuration>";
  PrintWriter writer = new PrintWriter(new FileOutputStream(tempResource));
  writer.println(newResource);
  writer.close();

  Configuration.addDefaultResource(rsrcName);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:24,代碼來源:TestRefreshUserMappings.java

示例12: indexDocs

import java.io.FileNotFoundException; //導入依賴的package包/類
public static void indexDocs(IndexWriter writer, File file)
  throws IOException {
  // do not try to index files that cannot be read
  if (file.canRead()) {
    if (file.isDirectory()) {
      String[] files = file.list();
      // an IO error could occur
      if (files != null) {
        for (int i = 0; i < files.length; i++) {
          indexDocs(writer, new File(file, files[i]));
        }
      }
    } else {
      System.out.println("adding " + file);
      try {
        writer.addDocument(FileDocument.Document(file));
      }
      // at least on windows, some temporary files raise this exception with an "access denied" message
      // checking if the file can be read doesn't help
      catch (FileNotFoundException fnfe) {
        ;
      }
    }
  }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:IndexFiles.java

示例13: InsertPerfInfoIntoFiles

import java.io.FileNotFoundException; //導入依賴的package包/類
static void InsertPerfInfoIntoFiles(String basePath, String cardName, String experimentID, HashMap<Short, Pair<Short, Long>> perfResultsSubpartsRaw) throws FileNotFoundException, IOException {
    File dir = new File(basePath);
    String[] filesArray = dir.list();
    if ((filesArray != null) && (dir.isDirectory() == true)) {
        // make subdir for results
        String outputDir = String.format("%s\\perf\\%s\\", basePath, experimentID);
        new File(outputDir).mkdirs();

        for (String fileName : filesArray) {
            File dir2 = new File(basePath + fileName);
            if (!dir2.isDirectory()) {
                InsertPerfInfoIntoFile(String.format("%s\\%s", basePath, fileName), cardName, experimentID, outputDir, perfResultsSubpartsRaw);
            }
        }
    }
}
 
開發者ID:OpenCryptoProject,項目名稱:Myst,代碼行數:17,代碼來源:MPCTestClient.java

示例14: downloadRawUserFile

import java.io.FileNotFoundException; //導入依賴的package包/類
@Override
public byte[] downloadRawUserFile(final String userId, final String fileName) {
  final Result<byte[]> result = new Result<byte[]>();
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        UserFileData ufd = datastore.find(userFileKey(userKey(userId), fileName));
        if (ufd != null) {
          result.t = ufd.content;
        } else {
          throw CrashReport.createAndLogError(LOG, null, collectUserErrorInfo(userId, fileName),
              new FileNotFoundException(fileName));
        }
      }
    }, true);
  } catch (ObjectifyException e) {
    throw CrashReport.createAndLogError(LOG, null, collectUserErrorInfo(userId, fileName), e);
  }
  return result.t;
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:22,代碼來源:ObjectifyStorageIo.java

示例15: init

import java.io.FileNotFoundException; //導入依賴的package包/類
public void init() throws Exception, CertificateException, FileNotFoundException, IOException {
if(sipStack.securityManagerProvider.getKeyManagers(false) == null ||
		sipStack.securityManagerProvider.getTrustManagers(false) == null ||
              sipStack.securityManagerProvider.getTrustManagers(true) == null) {
	if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
              logger.logDebug("TLS initialization failed due to NULL security config");
          }
	return; // The settings 
}
	
      sslServerCtx = SSLContext.getInstance("TLS");
      sslServerCtx.init(sipStack.securityManagerProvider.getKeyManagers(false), 
              sipStack.securityManagerProvider.getTrustManagers(false),
              null);

      sslClientCtx = SSLContext.getInstance("TLS");
      sslClientCtx.init(sipStack.securityManagerProvider.getKeyManagers(true),
              sipStack.securityManagerProvider.getTrustManagers(true),
              null);

  }
 
開發者ID:YunlongYang,項目名稱:LightSIP,代碼行數:22,代碼來源:NioTlsWebSocketMessageProcessor.java


注:本文中的java.io.FileNotFoundException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。