DZone 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

Snippets has posted 5883 posts at DZone. View Full User Profile

Java: Reading String From A File

  • submit to reddit
        // Ref:

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