Read file ID from the database. If it does not exits, then insert it to the database and return the file ID.

@param filePath  File to insert
@param conn      Database connection
@return          File ID in the database
421151
private int getFileId(Path filePath, Connection conn) throws SQLException {
        int fileId = readFileId(filePath, conn);
        if (fileId == -1) {
            Statement stmt = conn.createStatement();
            String insertFileSql = "insert into file (path, name) values ('" + filePath.getParent()
                    + "', '" + filePath.getFileName() + "');";
            stmt.executeUpdate(insertFileSql);
            stmt.close();

            fileId = readFileId(filePath, conn);
            if (fileId == -1) {
                throw new InternalError("Impossible to read the ID for the file " + filePath + " in database "
                        + databasePath);
            }

            stmt.close();
        }

        return fileId;
    }
816738
private URI findFile(final String filePath, final boolean upload) {
        try {
            URI fileURI;
            try {
                fileURI = _hadoopDefaultFS.getUri().resolve(filePath);
            } catch (final Exception e) {
                fileURI = null;
            }

            if ((fileURI == null || !_hadoopDefaultFS.exists(new Path(fileURI))) && upload) {
                final File file = new File(filePath);
                if (!file.isFile()) {
                    throw new IllegalArgumentException("'" + filePath + " does not exist, or is not a file");
                }

                final String fileName = file.toPath().getFileName().toString();
                return _applicationDriver
                        .copyFileToHdfs(file, DATACLEANER_TEMP_DIR + "/" + UUID.randomUUID() + fileName);
            }

            return fileURI;
        } catch (final IOException e) {
            throw new IllegalArgumentException("Path '" + filePath + "' is not a proper file path");
        }
    }
477706
def ReadFromPath(filepath):
  
  with io.open(filepath, mode="r", encoding="utf-8") as filedesc:
    return ReadFromFile(filedesc)
533477
public static FileInputStream getFileInputStream(String filePath) throws Exception {
        FileInputStream localFileInputStream = new FileInputStream(filePath);
        return localFileInputStream;
    }
963977
public static byte[] read2ByteArray(String filePath) {
        try {
            BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(new File(filePath)));
            byte[] byteArr = new byte[bufferedInputStream.available()];
            bufferedInputStream.read(byteArr);
            bufferedInputStream.close();
            return byteArr;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
622323
public void ENsavehydfile( String filePath ) throws EpanetException {
        int err = epanet.ENsavehydfile(filePath);
        checkError(err);
    }
462698
public synchronized void loadConfig(String filePath) throws Exception {

        if (isLoaded) {
            return;
        }

        String filePathInternal = filename;

        if (filePath != null) {

            filePathInternal = filePath;
        }

        DisconfAutowareConfig.autowareConfig(INSTANCE, filePathInternal);

        isLoaded = true;
    }
440250
public <X> DataSource<X> readFile(FileInputFormat<X> inputFormat, String filePath) {
		if (inputFormat == null) {
			throw new IllegalArgumentException("InputFormat must not be null.");
		}
		if (filePath == null) {
			throw new IllegalArgumentException("The file path must not be null.");
		}

		inputFormat.setFilePath(new Path(filePath));
		try {
			return createInput(inputFormat, TypeExtractor.getInputFormatTypes(inputFormat));
		}
		catch (Exception e) {
			throw new InvalidProgramException("The type returned by the input format could not be automatically determined. " +
					"Please specify the TypeInformation of the produced type explicitly by using the " +
					"'createInput(InputFormat, TypeInformation)' method instead.");
		}
	}
1266967
public static String read(String filePath) throws IOException, NotFoundException {
        BufferedImage image = ImageIO.read(new File(filePath));
        return read(image);
    }
364686
public List<DependencyInfo> parseFile(String filePath) throws IOException {
    return parseFileReader(filePath, Files.newReader(new File(filePath), StandardCharsets.UTF_8));
  }
950788
public static StoreConfig newInstance(File filePath) throws IOException {
        File homeDir;
        Properties p = new Properties();
        if(filePath.exists()) {
            if(filePath.isDirectory()) {
                homeDir = filePath;
                File propertiesFile = new File(filePath, CONFIG_PROPERTIES_FILE);
                if(propertiesFile.exists()) {
                    FileReader reader = new FileReader(propertiesFile);
                    p.load(reader);
                    reader.close();
                } else {
                    throw new FileNotFoundException(propertiesFile.toString());
                }
            } else {
                homeDir = filePath.getParentFile();
                FileReader reader = new FileReader(filePath);
                p.load(reader);
                reader.close();
            }
        } else {
            throw new FileNotFoundException(filePath.toString());
        }
        
        int initialCapacity = -1;
        String initialCapacityStr = p.getProperty(StoreParams.PARAM_INITIAL_CAPACITY);
        if(initialCapacityStr == null) {
            throw new InvalidStoreConfigException(StoreParams.PARAM_INITIAL_CAPACITY + " not found");
        } else if((initialCapacity = parseInt(StoreParams.PARAM_INITIAL_CAPACITY, initialCapacityStr, -1)) < 1) {
            throw new InvalidStoreConfigException(StoreParams.PARAM_INITIAL_CAPACITY + "=" + initialCapacityStr);
        }
        
        int partitionStart = -1;
        int partitionCount = -1;
        String partitionStartStr = p.getProperty(StoreParams.PARAM_PARTITION_START);
        String partitionCountStr = p.getProperty(StoreParams.PARAM_PARTITION_COUNT);
        if(partitionStartStr != null && partitionCountStr != null) {
            if((partitionStart = parseInt(StoreParams.PARAM_PARTITION_START, partitionStartStr, -1)) < 0) {
                throw new InvalidStoreConfigException(StoreParams.PARAM_PARTITION_START + "=" + partitionStartStr);
            }
            
            if((partitionCount = parseInt(StoreParams.PARAM_PARTITION_COUNT, partitionCountStr, -1)) < 1) {
                throw new InvalidStoreConfigException(StoreParams.PARAM_PARTITION_COUNT + "=" + partitionCountStr);
            }
        } else {
            return new StoreConfig(homeDir, initialCapacity);
        }
        
        return new StorePartitionConfig(homeDir, partitionStart, partitionCount);
    }
1261836
public static String getFileName(String filePath) {
       int separatorIndex = filePath.lastIndexOf(separator);
       return separatorIndex < 0 ? filePath : filePath.substring(separatorIndex + 1,
    		   filePath.length());
   }
1120927
public void open(String filePath, final long filePosition) throws FileNotFoundException, IOException {
        open(new File(filePath), filePosition);
    }
1047299
public static boolean checkIfFileExists(String filePath) {
        File file = new File(filePath);// getSDCardPath(), filePath);
        return (file.exists() ? true : false);
    }
207240
public void read(String filePath) throws IOException{


		String line;
		ArrayList<String> words = new ArrayList<String>();
		ArrayList<String> markP = new ArrayList<String>();
		ArrayList<String> typeP = new ArrayList<String>();
		ArrayList<String> markC = new ArrayList<String>();
		ArrayList<String> typeC = new ArrayList<String>();
		if(filePath == null)
			return;
		File file = new File(filePath);
		BufferedReader reader = null;
		entityType = new HashSet<String>();

		//按行读取文件内容，一次读一整行
		reader = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8"));

		//从文件中提取实体并存入队列中

		while ((line = reader.readLine()) != null) {
			line = line.trim();
			if(line.equals("")){

				newextract(words, markP, typeP, markC, typeC);


			}else{
				//判断实体,实体开始的边界为B-***或者S-***，结束的边界为E-***或N（O）或空白字符或B-***
				//predict
				String[] toks = line.split("\\s+");

				int ci = 1;
				int cj=2;

				if(toks.length>3){//如果列数大于三，默认取最后两列
					ci=toks.length-2;
					cj=toks.length-1;
				}else if(toks.length<3){
					System.out.println(line);
					return;
				}

				String[] marktype = getMarkType(toks[ci]);
				words.add(toks[0]);
				markP.add(marktype[0]);
				typeP.add(marktype[1]);
				entityType.add(marktype[1]);	

				//correct
				marktype = getMarkType(toks[cj]);
				markC.add(marktype[0]);
				typeC.add(marktype[1]);	
				entityType.add(marktype[1]);	

			}
		}
		reader.close();
		if(words.size()>0){
			newextract(words, markP, typeP, markC, typeC);
		}
		//从entityPs和entityCs提取正确估计的实体，存到entityCinPs，并更新mpc中的统计信息
		extractCInPEntity();
	}
362364
public static String getFileContent(String filePath, long offset, int length) throws Exception {
        FileInputStream fileInputStream = null;
        try {
            fileInputStream = getFileInputStream(filePath);
            return getFileContent(fileInputStream, offset, length);
        } finally {
            closeFileStream(fileInputStream, filePath);
        }
    }
695531
@Override
	public String load(final String filePath) {
		if (StringUtils.isEmpty(filePath)) {
			throw new IllegalArgumentException("Invalid file path. filePath=" + filePath);
		}
		String targetFilePath = getFilePath(trimSqlExtension(filePath.replace(".", PATH_SEPARATOR)));
		String sql = null;

		URL resource = Thread.currentThread().getContextClassLoader().getResource(targetFilePath);
		if (resource != null) {
			try (InputStream is = resource.openStream()) {

				sql = trimSlash(read(new BufferedReader(new InputStreamReader(is))));

				LOG.debug("Loaded SQL template.[{}]", targetFilePath);
			} catch (IOException e) {
				throw new UroborosqlRuntimeException("Failed to load SQL template[" + targetFilePath + "].", e);
			}
		}

		if (sql == null) {
			throw new UroborosqlRuntimeException("SQL template could not found.[" + targetFilePath + "]");
		}
		return sql;
	}