Created
March 24, 2011 16:17
-
-
Save MetalBeetle/885338 to your computer and use it in GitHub Desktop.
BufferedOutputStream Considered Harmful
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bufferedoutputstreamtest; | |
import java.io.BufferedOutputStream; | |
import java.io.IOException; | |
import java.io.OutputStream; | |
/** | |
* Contrary to what you'd expect, this runs with no exception thrown. | |
* Thanks, BufferedOutputStream! | |
*/ | |
public class Main { | |
public static void main(String[] args) throws IOException { | |
OutputStream crashy = new OutputStream() { | |
@Override | |
public void write(int i) throws IOException { | |
throw new IOException("crash"); | |
} | |
}; | |
BufferedOutputStream bos = new BufferedOutputStream(crashy); | |
bos.write(33); | |
bos.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment