Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Java: Reading String from a File (See related posts)

// Ref: http://www.exampledepot.com/egs/java.util.regex/Comment.html

    try {
        File f = new File("pattern.txt");
        FileReader rd = new FileReader(f);
        char[] buf = new char[(int)f.length()];
        rd.read(buf);
        patternStr = new String(buf);
    
        matcher = pattern.matcher(inputStr);
        matchFound = matcher.matches();
    } catch (IOException e) {
    }

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts