Clover icon

sunshower-base

  1. Project Clover database Fri Apr 6 2018 03:41:27 UTC
  2. Package io.sunshower.common.io

File Bytes.java

 

Coverage histogram

../../../../img/srcFileCovDistChart7.png
25% of files have more coverage

Code metrics

2
9
2
1
22
18
5
0.56
4.5
2
2.5

Classes

Class Line # Actions
Bytes 5 9 5
0.692307769.2%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    package io.sunshower.common.io;
2   
3    import java.io.*;
4   
 
5    public class Bytes {
6   
 
7  0 toggle public static byte[] read(File file) throws IOException {
8  0 return read(new BufferedInputStream(new FileInputStream(file)));
9    }
10   
 
11  1 toggle public static byte[] read(InputStream inputStream) throws IOException {
12  1 final ByteArrayOutputStream output = new ByteArrayOutputStream(8192);
13  1 final byte[] data = new byte[1024];
14  1 int read;
15  1 try (InputStream is = inputStream) {
16  ? while ((read = inputStream.read(data)) != -1) {
17  1 output.write(data, 0, read);
18    }
19    }
20  1 return output.toByteArray();
21    }
22    }