forked from I2P_Developers/i2p.i2p
* Base64: Add decodestring command in main()
This commit is contained in:
@@ -184,6 +184,19 @@ public class Base64 {
|
|||||||
System.out.println(encode(args[1].getBytes()));
|
System.out.println(encode(args[1].getBytes()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ("decodestring".equals(cmd)) {
|
||||||
|
byte[] dec = decode(args[1]);
|
||||||
|
if (dec != null) {
|
||||||
|
try {
|
||||||
|
System.out.write(dec);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
System.err.println("output error " + ioe);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.err.println("decode error");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
InputStream in = System.in;
|
InputStream in = System.in;
|
||||||
OutputStream out = System.out;
|
OutputStream out = System.out;
|
||||||
try {
|
try {
|
||||||
@@ -238,6 +251,8 @@ public class Base64 {
|
|||||||
System.out.println("or : Base64 decode <inFile> <outFile>");
|
System.out.println("or : Base64 decode <inFile> <outFile>");
|
||||||
System.out.println("or : Base64 decode <inFile>");
|
System.out.println("or : Base64 decode <inFile>");
|
||||||
System.out.println("or : Base64 decode");
|
System.out.println("or : Base64 decode");
|
||||||
|
System.out.println("or : Base64 encodestring 'string to encode'");
|
||||||
|
System.out.println("or : Base64 decodestring 'string to decode'");
|
||||||
System.out.println("or : Base64 test");
|
System.out.println("or : Base64 test");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,6 +699,7 @@ public class Base64 {
|
|||||||
* returns it as a string.
|
* returns it as a string.
|
||||||
* Equivlaent to calling
|
* Equivlaent to calling
|
||||||
* <code>new String( decode( s ) )</code>
|
* <code>new String( decode( s ) )</code>
|
||||||
|
* WARNING this uses the locale's encoding, it may not be what you want.
|
||||||
*
|
*
|
||||||
* @param s the strind to decode
|
* @param s the strind to decode
|
||||||
* @return The data as a string
|
* @return The data as a string
|
||||||
|
Reference in New Issue
Block a user