mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-22 06:01:12 +00:00
Added readline
This commit is contained in:
parent
36b0d6ba03
commit
7f82f9d4db
1 changed files with 12 additions and 0 deletions
|
@ -2578,6 +2578,18 @@ public class Helper {
|
|||
return os.toByteArray();
|
||||
}
|
||||
|
||||
public static String readLine(InputStream is, Charset charset) throws IOException {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
int b = is.read();
|
||||
if (b < 0)
|
||||
return null;
|
||||
while (b >= 0 && b != '\n') {
|
||||
bos.write(b);
|
||||
b = is.read();
|
||||
}
|
||||
return new String(bos.toByteArray(), charset);
|
||||
}
|
||||
|
||||
static void copy(File src, File dst) throws IOException {
|
||||
try (InputStream is = new FileInputStream(src)) {
|
||||
try (OutputStream os = new FileOutputStream(dst)) {
|
||||
|
|
Loading…
Reference in a new issue