bacoAlunos
ENGSOFT2019
BlueGrey
calm
Elegant
Català-Valencià - Catalan
中文 - Chinese (Simplified)
中文 - Chinese (Traditional)
Česky - Czech
Dansk - Danish
Nederlands - Dutch
English - English
Suomi - Finnish
Français - French
Deutsch - German
עברית - Hebrew
हिंदी - Hindi
Magyar - Hungarian
Bahasa Indonesia - Indonesian
Italiano - Italian
日本語 - Japanese
한국어 - Korean
मराठी - Marathi
Norsk - Norwegian
Polski - Polish
Português - Portuguese
Português - Portuguese (Brazil)
Русский - Russian
Slovenčina - Slovak
Slovenščina - Slovenian
Español - Spanish
Svenska - Swedish
Türkçe - Turkish
Oëzbekcha - Uzbek
Subversion Repositories
bacoAlunos
(root)
/
impl
/
src
/
java
/
jomm
/
utils
/
StreamsUtils.java
@ 333
- Rev
Rev
Rev 297
|
Blame
|
Compare with Previous
|
Last modification
|
View Log
|
RSS feed
package
jomm.utils
;
import
java.io.*
;
/**
* @author Jorge Machado
* @date 27/Mai/2008
* @see jomm.utils
*/
public
class
StreamsUtils
{
public
static
byte
[
]
readBytes
(
5+
0
%
2Fdocs
%
2Fapi+InputStream">
InputStream
stream
)
throws
1.
5
.0/docs/api/java/io/IOException.html">
IOException
{
1.
5
.0/docs/api/java/io/ByteArrayOutputStream.html">
ByteArrayOutputStream
b =
new
1.
5
.0/docs/api/java/io/ByteArrayOutputStream.html">
ByteArrayOutputStream
(
)
;
int
readedBytes
;
byte
[
]
buf =
new
byte
[
1024
]
;
while
(
(
readedBytes = stream.
read
(
buf
)
)
>
0
)
{
b.
write
(
buf, 0, readedBytes
)
;
}
b.
close
(
)
;
return
b.
toByteArray
(
)
;
}
public
static
1.
5
.0/docs/api/java/lang/String.html">
String
readString
(
5+
0
%
2Fdocs
%
2Fapi+InputStream">
InputStream
stream
)
throws
1.
5
.0/docs/api/java/io/IOException.html">
IOException
{
1.
5
.0/docs/api/java/io/ByteArrayOutputStream.html">
ByteArrayOutputStream
b =
new
1.
5
.0/docs/api/java/io/ByteArrayOutputStream.html">
ByteArrayOutputStream
(
)
;
int
readedBytes
;
byte
[
]
buf =
new
byte
[
1024
]
;
while
(
(
readedBytes = stream.
read
(
buf
)
)
>
0
)
{
b.
write
(
buf, 0, readedBytes
)
;
}
b.
close
(
)
;
return
b.
toString
(
)
;
}
public
static
void
inputStream2File
(
5+
0
%
2Fdocs
%
2Fapi+InputStream">
InputStream
stream,
1.
5
.0/docs/api/java/io/File.html">
File
f
)
throws
1.
5
.0/docs/api/java/io/IOException.html">
IOException
{
f.
getParentFile
(
)
.
mkdirs
(
)
;
1.
5
.0/docs/api/java/io/FileOutputStream.html">
FileOutputStream
out =
new
1.
5
.0/docs/api/java/io/FileOutputStream.html">
FileOutputStream
(
f
)
;
inputStream2OutputStream
(
stream,out
)
;
}
public
static
void
inputStream2OutputStream
(
5+
0
%
2Fdocs
%
2Fapi+InputStream">
InputStream
stream,
5+
0
%
2Fdocs
%
2Fapi+OutputStream">
OutputStream
out
)
throws
1.
5
.0/docs/api/java/io/IOException.html">
IOException
{
int
readedBytes
;
byte
[
]
buf =
new
byte
[
1024
]
;
while
(
(
readedBytes = stream.
read
(
buf
)
)
>
0
)
{
out.
write
(
buf, 0, readedBytes
)
;
}
stream.
close
(
)
;
out.
close
(
)
;
}
}