Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
More Jobs
Recent
Before Filter URL Redirect if URL is messed with
Morse Code Encoder/Decoder
Source code analysis
Timer Class
Remove the Evil GOTO
Mortgage Calculator
Interactive CLI Session
Format Filesize
Camelize
Map fields array and data arrays into an array of hashes
Popular
Morse Code Encoder/Decoder
Before Filter URL Redirect if URL is messed with
Map fields array and data arrays into an array of hashes
Camelize
Interactive CLI Session
Mortgage Calculator
Remove the Evil GOTO
Source code analysis
Format Filesize
Timer Class
Pastable version of
Read and write example
<div style="overflow:auto;border:solid 1px #ccc;background:#000;color:#F8F8F8"> <div class="section"> <pre style="float:left;margin:0 10px;border-right:0;color:#666;">1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24</pre> <pre class="sunburst"><span style="color:#AEAEAE;font-style:italic;"><span style="color:#AEAEAE;font-style:italic;">/**</span></span> <span style="color:#AEAEAE;font-style:italic;"> * This example show how to read from the keyboard and write to the</span> <span style="color:#AEAEAE;font-style:italic;"> * monitor one char. ! This is only an example ! Use Reader and </span> <span style="color:#AEAEAE;font-style:italic;"> * Writer sub-classes for working with characters.</span> <span style="color:#AEAEAE;font-style:italic;"> <span style="color:#AEAEAE;font-style:italic;">*/</span></span> <span style="color:#E28964;">import</span> <span style="text-decoration:underline;">java.io.*</span>; <span style="color:#99CF50;">public </span><span style="color:#99CF50;">class</span> <span style="text-decoration:underline;">ReadAndWrite</span> { <span style="color:#99CF50;">public static </span><span style="color:#99CF50;">void</span> <span style="color:#89BDFF;">main</span>(<span style="color:#9B859D;">String</span>[] args) { <span style="color:#99CF50;">int</span> ch = <span style="color:#3387CC;">0</span>; <span style="color:#9B859D;">BufferedInputStream</span> keyboard = <span style="color:#E28964;">new</span> <span style="color:#9B859D;">BufferedInputStream</span>(<span style="color:#9B859D;">System</span>.in); <span style="color:#9B859D;">BufferedOutputStream</span> monitor = <span style="color:#E28964;">new</span> <span style="color:#9B859D;">BufferedOutputStream</span>(<span style="color:#9B859D;">System</span>.out); <span style="color:#E28964;">try</span> { ch = keyboard.read(); monitor.write(ch); monitor.flush(); } <span style="color:#E28964;">catch</span>(<span style="color:#9B859D;">IOException</span> e) {} } } </pre> </div> </div> <a href="http://refactormycode.com/codes/274-read-and-write-example" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://refactormycode.com/images/small_logo.gif" style="border:0" /></a>