Parses a source file.

@param file  the file being read, not null
@throws Exception if an error occurs
762779
private void parseFile(File file) throws Exception {
        int lineNumber = 1;
        String line = null;
        BufferedReader in = null;
        try {
            in = new BufferedReader(new FileReader(file));
            List<TZDBZone> openZone = null;
            for ( ; (line = in.readLine()) != null; lineNumber++) {
                int index = line.indexOf('#');  // remove comments (doesn't handle # in quotes)
                if (index >= 0) {
                    line = line.substring(0, index);
                }
                if (line.trim().length() == 0) {  // ignore blank lines
                    continue;
                }
                StringTokenizer st = new StringTokenizer(line, " \t");
                if (openZone != null && Character.isWhitespace(line.charAt(0)) && st.hasMoreTokens()) {
                    if (parseZoneLine(st, openZone)) {
                        openZone = null;
                    }
                } else {
                    if (st.hasMoreTokens()) {
                        String first = st.nextToken();
                        if (first.equals("Zone")) {
                            if (st.countTokens() < 3) {
                                printVerbose("Invalid Zone line in file: " + file + ", line: " + line);
                                throw new IllegalArgumentException("Invalid Zone line");
                            }
                            openZone = new ArrayList<TZDBZone>();
                            zones.put(st.nextToken(), openZone);
                            if (parseZoneLine(st, openZone)) {
                                openZone = null;
                            }
                        } else {
                            openZone = null;
                            if (first.equals("Rule")) {
                                if (st.countTokens() < 9) {
                                    printVerbose("Invalid Rule line in file: " + file + ", line: " + line);
                                    throw new IllegalArgumentException("Invalid Rule line");
                                }
                                parseRuleLine(st);

                            } else if (first.equals("Link")) {
                                if (st.countTokens() < 2) {
                                    printVerbose("Invalid Link line in file: " + file + ", line: " + line);
                                    throw new IllegalArgumentException("Invalid Link line");
                                }
                                String realId = st.nextToken();
                                String aliasId = st.nextToken();
                                links.put(aliasId, realId);

                            } else {
                                throw new IllegalArgumentException("Unknown line");
                            }
                        }
                    }
                }
            }
        } catch (Exception ex) {
            throw new Exception("Failed while processing file '" + file + "' on line " + lineNumber + " '" + line + "'", ex);
        } finally {
            if (in != null) {
                in.close();
            }
        }
    }
481836
public Document parse(File file) throws SAXException, IOException
    {
        return verify(_WrappedBuilder.parse(file));
    }
344718
public void parse(File f, DefaultHandler dh) throws SAXException, IOException
    {
        XMLReader reader = getXMLReader();
        InputSource source = new InputSource(new FileInputStream(f));
        reader.setContentHandler(dh);
        reader.parse(source);
    }
280183
public static Parameters parse(File file, String encoding) throws AponParseException {
        if (file == null) {
            throw new IllegalArgumentException("file must not be null");
        }
        Parameters parameters = new VariableParameters();
        return parse(file, encoding, parameters);
    }
73522
private void parse(String fileName) throws IOException, SAXException {
        FileInputStream fileInputStream = new FileInputStream(new File(fileName));
        parse(fileName, fileInputStream);
    }
1133335
public static void parseFile(final IVdmSourceUnit source)
			throws CoreException, IOException
	{
		try
		{
			ISourceParser parser = SourceParserManager.getInstance()
					.getSourceParser(source.getProject());
			Assert.isNotNull(parser, "No parser for file : "
					+ source.toString() + " in project "
					+ source.getProject().toString());
			parser.parse(source);
		} catch (Exception e)
		{
			if (VdmCore.DEBUG)
			{
//				System.err.println("Error in parseFile");
				VdmCore.log("SourceParseManager-Error in parseFile", e);
			}
		}
	}
523966
public void file(File file) {
        try {
            contentLength(file.length());
            file(file.getName(), new FileInputStream(file));
        } catch (FileNotFoundException e) {
            throw new PippoRuntimeException(e);
        }
    }
887546
public ResourceFormatParser getParserForFileExtension(final File file) throws UnsupportedFormatException {
        String extension = getFileExtension(file.getName());
        if (null != extension) {
            return getParserForFileExtension(extension);
        } else {
            throw new UnsupportedFormatException("Could not determine format for file: " + file.getAbsolutePath());
        }
    }
199008
public static XmlReport parse( File file ) throws Exception
	{
		Reader in = BOMUtil.newReader( file );

		try
		{
			return parse( in );
		}
		finally
		{
			IOUtil.closeQuietly( in );
		}
	}
564494
public void load(String file) throws Exception {

		try {
			InputStreamReader  read = new InputStreamReader (new FileInputStream(file),"utf-8");
			BufferedReader lbin = new BufferedReader(read);
			String str;
			while((str=lbin.readLine())!=null){
				if(str.length()==0)
					continue;
				if(str.charAt(0)=='#')
					continue;
				add(new BaseTemplet(gid++, str));
			}
			lbin.close();
		} catch (IOException e1) {
			e1.printStackTrace();
			throw new Exception("读入模板错误");
		}catch (Exception e) {
			e.printStackTrace();
			throw new Exception("读入模板错误");
		}
	}
1320142
public static Source source(File file) throws FileNotFoundException {
    if (file == null) throw new IllegalArgumentException("file == null");
    return source(new FileInputStream(file));
  }
399171
public void parse(File xmlFile) throws XMLStreamException {
    try (InputStream input = java.nio.file.Files.newInputStream(xmlFile.toPath())) {
      parse(input);
    } catch (IOException e) {
      LOG.debug("Cannot access file", e);
    }
  }
1357282
@Override
    public Collection<DependencyInfo> parse(File file) {
        BufferedReader br = null;
        FileReader fr = null;
        Collection<DependencyInfo> dependencyInfos = new LinkedList<>();
        try {
            fr = new FileReader(file.getAbsoluteFile());
            br = new BufferedReader(fr);
            String line = null;
            Package packageInfo = new Package();
            // Create Alpine package - package-version-architecture.apk
            while ((line = br.readLine()) != null) {
                if (!line.isEmpty()) {
                    if (packageInfo.getPackageName() == null || packageInfo.getVersion() == null || packageInfo.getArchitecture() == null) {
                        String[] lineSplit = line.split(Constants.COLON);
                        String dependencyParameter = lineSplit[1].trim();
                        switch (lineSplit[0]) {
                            case PACKAGE:
                                packageInfo.setPackageName(dependencyParameter);
                                break;
                            case VERSION:
                                packageInfo.setVersion(dependencyParameter);
                                break;
                            case ARCHITECTURE:
                                packageInfo.setArchitecture(dependencyParameter);
                                break;
                            default:
                                break;
                        }
                    }
                } else {
                    DependencyInfo dependencyInfo = createDependencyInfo(packageInfo);
                    packageInfo = new Package();
                    dependencyInfos.add(dependencyInfo);
                }
            }
        } catch (Exception e) {
            logger.error(e.getMessage());
            logger.debug("{}", e.getStackTrace());
        } finally {
            closeStream(br, fr);
        }
        return dependencyInfos;
    }
703458
private Object parseFile(File file, String scharset) {
        Charset charset = scharset==null || scharset.length ()==0 ? StandardCharsets.UTF_8 : Charset.forName ( scharset );

        if (file.length() > 2_000_000) {
            try (Reader reader = Files.newBufferedReader( Classpaths.path(file.toString()), charset )) {
                return parse(reader);
            } catch(IOException ioe) {
                throw new JsonException("Unable to process file: " + file.getPath(), ioe);
            }
        } else {
            try {
                return JsonFactory.create().fromJson ( Files.newBufferedReader( Classpaths.path(file.toString()), charset ) );
            } catch ( IOException e ) {
                throw new JsonException("Unable to process file: " + file.getPath(), e);
            }
        }
    }
1277630
static function parse_file( $f ){
		$src = file_get_contents( $f, true );
		if( $src === false ){
			throw new Exception("Cannot read file $f");
		}
		return self::parse_string( $src );
	}
602736
public static void doFile(File f)
                              throws Exception {
        // If this is a directory, walk each file/dir in that directory
        if (f.isDirectory()) {
            String files[] = f.list();
            for(int i=0; i < files.length; i++)
                doFile(new File(f, files[i]));
        }

        // otherwise, if this is a groovy file, parse it!
        else if (f.getName().endsWith(".groovy")) {
            System.err.println(" --- "+f.getAbsolutePath());
            // parseFile(f.getName(), new FileInputStream(f));
            SourceBuffer sourceBuffer = new SourceBuffer();
            UnicodeEscapingReader unicodeReader = new UnicodeEscapingReader(new FileReader(f),sourceBuffer);
            GroovyLexer lexer = new GroovyLexer(unicodeReader);
            unicodeReader.setLexer(lexer);
            parseFile(f.getName(),lexer,sourceBuffer);
        }
    }

    // Here's where we do the real work...
    public static void parseFile(String f, GroovyLexer l, SourceBuffer sourceBuffer)
                                 throws Exception {
        try {
            // Create a parser that reads from the scanner
            GroovyRecognizer parser = GroovyRecognizer.make(l);
            parser.setSourceBuffer(sourceBuffer);
            parser.setFilename(f);
                        
                        if (whitespaceIncluded) {
                            GroovyLexer lexer = parser.getLexer();
                            lexer.setWhitespaceIncluded(true);
                            while (true) {
                                Token t = lexer.nextToken();
                                System.out.println(t);
                                if (t == null || t.getType() == Token.EOF_TYPE)  break;
                            }
                            return;
                        }

            // start parsing at the compilationUnit rule
            parser.compilationUnit();
            
            System.out.println("parseFile "+f+" => "+parser.getAST());

            // do something with the tree
            doTreeAction(f, parser.getAST(), parser.getTokenNames());
        }
214437
public void readXML(File file) throws IOException, DocumentException {
        project.setCurrentWorkingDirectory(file.getParentFile());
        dataSource = file.getAbsolutePath();
        InputStream in = progessMonitoredInputStream(file, "Loading analysis");
        try {
            readXML(in, file);
        } catch (IOException e) {
            throw newIOException(file, e);
        } catch (DocumentException e) {
            throw new DocumentException("Failing reading " + file, e);
        }
    }