Unbuffered write in loop

View: New views
1 Messages — Rating Filter:   Alert me  

Parent Message unknown Unbuffered write in loop

by Sam Beroz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Would it be possible to detect the direct use of a FileWriter / OutputStream within a loop?  I've come across the following and forgetting to wrap an output destination in a BufferedWriter / BufferedOutputStream can really kill performance:

        Writer writer = null;
        try {
            writer = new FileWriter("test.out");
            for (int i = 0; i < 100000; i++) {
                writer.append('X'); //unbuffered output to disk!
            }
        } catch (IOException e) {
                System.err.println("an exception was thrown ...");
        } finally {
            try {
                if (null != writer)
                    writer.close();
            } catch (IOException e) {
                System.err.println("error closing stream ...");
            }
        }

Would further decorating the unbuffered desitination with a PrintWriter cause detection issues?
Thanks. - Sam Beroz



     
_______________________________________________
Findbugs-discuss mailing list
Findbugs-discuss@...
https://mailman.cs.umd.edu/mailman/listinfo/findbugs-discuss