?

public ? static ? void ?copy(InputStream?in,?OutputStream?out)
???
throws ?IOException? {
??
try ? {
???
synchronized ?(in)? {
????
synchronized ?(out)? {
?????
byte []?buffer? = ? new ? byte [ 256 ];
?????
// start?copy
????? while ?( true )? {
??????
int ?bytesRead? = ?in.read(buffer);
??????
if ?(bytesRead? == ? - 1 )
???????
break ;
??????out.write(buffer,?
0 ,?bytesRead);
?????}

?????
// end?copy
?????out.flush();
????}

???}

??}
? catch ?(IOException?e)? {
???
throw ?e;
??}
? finally ? {
???out.close();
???in.close();
??}