Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Java: Reading String From A File

DZone's Guide to

Java: Reading String From A File

·
Free Resource
// 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:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}