src/java.base/share/classes/sun/security/util/BitArray.java
changeset 59141 bd436284147d
parent 47216 71c04702a3d5
equal deleted inserted replaced
59140:f68fd04fe463 59141:bd436284147d
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   239 
   239 
   240     /**
   240     /**
   241      *  Returns a string representation of this BitArray.
   241      *  Returns a string representation of this BitArray.
   242      */
   242      */
   243     public String toString() {
   243     public String toString() {
       
   244         if (length == 0) {
       
   245             return "";
       
   246         }
       
   247 
   244         ByteArrayOutputStream out = new ByteArrayOutputStream();
   248         ByteArrayOutputStream out = new ByteArrayOutputStream();
   245 
   249 
   246         for (int i = 0; i < repn.length - 1; i++) {
   250         for (int i = 0; i < repn.length - 1; i++) {
   247             out.write(NYBBLE[(repn[i] >> 4) & 0x0F], 0, 4);
   251             out.write(NYBBLE[(repn[i] >> 4) & 0x0F], 0, 4);
   248             out.write(NYBBLE[repn[i] & 0x0F], 0, 4);
   252             out.write(NYBBLE[repn[i] & 0x0F], 0, 4);