jdk/src/java.base/share/classes/java/io/FilePermission.java
changeset 26219 1a19360ff122
parent 25859 3317bb8137f4
child 29986 97167d851fc4
--- a/jdk/src/java.base/share/classes/java/io/FilePermission.java	Wed Aug 27 11:33:45 2014 +0800
+++ b/jdk/src/java.base/share/classes/java/io/FilePermission.java	Wed Aug 27 22:08:19 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 import java.util.ArrayList;
 import java.util.Vector;
 import java.util.Collections;
+import java.util.StringJoiner;
 import sun.security.util.SecurityConstants;
 
 /**
@@ -556,39 +557,25 @@
      * @return the canonical string representation of the actions.
      */
     private static String getActions(int mask) {
-        StringBuilder sb = new StringBuilder();
-        boolean comma = false;
+        StringJoiner sj = new StringJoiner(",");
 
         if ((mask & READ) == READ) {
-            comma = true;
-            sb.append("read");
+            sj.add("read");
+        }
+        if ((mask & WRITE) == WRITE) {
+            sj.add("write");
         }
-
-        if ((mask & WRITE) == WRITE) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("write");
+        if ((mask & EXECUTE) == EXECUTE) {
+            sj.add("execute");
+        }
+        if ((mask & DELETE) == DELETE) {
+            sj.add("delete");
+        }
+        if ((mask & READLINK) == READLINK) {
+            sj.add("readlink");
         }
 
-        if ((mask & EXECUTE) == EXECUTE) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("execute");
-        }
-
-        if ((mask & DELETE) == DELETE) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("delete");
-        }
-
-        if ((mask & READLINK) == READLINK) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("readlink");
-        }
-
-        return sb.toString();
+        return sj.toString();
     }
 
     /**