You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2018/11/01 20:04:05 UTC
[5/8] jena git commit: wwwenc: read from stdin if called with no args
wwwenc: read from stdin if called with no args
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/85be62dd
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/85be62dd
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/85be62dd
Branch: refs/heads/master
Commit: 85be62dded8875d73b522d1008106fd82a1f1ce1
Parents: 6e81f9f
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Oct 26 14:47:23 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Oct 27 16:36:39 2018 +0100
----------------------------------------------------------------------
jena-cmds/src/main/java/arq/wwwenc.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/85be62dd/jena-cmds/src/main/java/arq/wwwenc.java
----------------------------------------------------------------------
diff --git a/jena-cmds/src/main/java/arq/wwwenc.java b/jena-cmds/src/main/java/arq/wwwenc.java
index 4ee19af..089f412 100644
--- a/jena-cmds/src/main/java/arq/wwwenc.java
+++ b/jena-cmds/src/main/java/arq/wwwenc.java
@@ -18,6 +18,9 @@
package arq;
+import java.io.IOException;
+
+import org.apache.jena.atlas.io.IO;
import org.apache.jena.atlas.lib.StrUtils ;
public class wwwenc
@@ -36,7 +39,7 @@ public class wwwenc
*
*
*/
- public static void main(String...args)
+ public static void main(String...args) throws IOException
{
// Reserved characters + space
char reserved[] =
@@ -47,8 +50,13 @@ public class wwwenc
char[] other = {'<', '>', '~', '.', '{', '}', '|', '\\', '-', '`', '_', '^'} ;
- for ( String x : args)
- {
+ if ( args.length == 0 ) {
+ String x = IO.readWholeFileAsUTF8(System.in);
+ String y = StrUtils.encodeHex(x, '%', reserved) ;
+ System.out.println(y) ;
+ return;
+ }
+ for ( String x : args) {
// Not URLEncoder which does www-form-encoding.
String y = StrUtils.encodeHex(x, '%', reserved) ;
System.out.println(y) ;