Over a million developers have joined DZone.

Java: Reading String From A File

·
// 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) {
    }
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}