mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Remove dependency on apache commons-io
This commit is contained in:
parent
fb5f2ca5fa
commit
4608fb433b
2 changed files with 16 additions and 3 deletions
|
@ -20,7 +20,6 @@ repositories {
|
|||
dependencies {
|
||||
compile 'org.whispersystems:signal-service-java:2.1.1fetchMessages_provisioning'
|
||||
compile 'org.bouncycastle:bcprov-jdk15on:1.54'
|
||||
compile 'commons-io:commons-io:2.5'
|
||||
compile 'net.sourceforge.argparse4j:argparse4j:0.7.0'
|
||||
compile 'org.freedesktop.dbus:dbus-java:2.7.0'
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.asamk.signal;
|
|||
import net.sourceforge.argparse4j.ArgumentParsers;
|
||||
import net.sourceforge.argparse4j.impl.Arguments;
|
||||
import net.sourceforge.argparse4j.inf.*;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.util.TextUtils;
|
||||
import org.asamk.Signal;
|
||||
import org.freedesktop.dbus.DBusConnection;
|
||||
|
@ -41,8 +40,11 @@ import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.Security;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -270,7 +272,7 @@ public class Main {
|
|||
String messageText = ns.getString("message");
|
||||
if (messageText == null) {
|
||||
try {
|
||||
messageText = IOUtils.toString(System.in);
|
||||
messageText = readAll(System.in);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Failed to read message from stdin: " + e.getMessage());
|
||||
System.err.println("Aborting sending.");
|
||||
|
@ -643,6 +645,18 @@ public class Main {
|
|||
System.err.println("Failed to send message: " + e.getMessage());
|
||||
}
|
||||
|
||||
private static String readAll(InputStream in) throws IOException {
|
||||
StringWriter output = new StringWriter();
|
||||
byte[] buffer = new byte[4096];
|
||||
long count = 0;
|
||||
int n;
|
||||
while (-1 != (n = System.in.read(buffer))) {
|
||||
output.write(new String(buffer, 0, n, Charset.defaultCharset()));
|
||||
count += n;
|
||||
}
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
private static class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||
final Manager m;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue