Skip to content

Commit

Permalink
#452 removed dependency on Java 8
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanrauh committed Jul 6, 2016
1 parent 86a4d15 commit a2e277e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/net/bootsfaces/utils/BsfUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Base64;
import java.util.Iterator;
import java.util.Locale;
import java.util.MissingResourceException;
Expand All @@ -23,6 +22,7 @@
import javax.faces.component.UIViewRoot;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.xml.bind.DatatypeConverter;

public class BsfUtils {

Expand Down Expand Up @@ -526,7 +526,8 @@ public static String getLabel(FacesContext context, UIComponent comp) {
*/
public static Object fromString(String s) {
try {
byte [] data = Base64.getDecoder().decode( s );
byte[] data = DatatypeConverter.parseBase64Binary(s);
// byte [] data = Base64.getDecoder().decode( s );
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(data));
Object o = ois.readObject();
ois.close();
Expand All @@ -548,7 +549,9 @@ public static String toString(Serializable o) {
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(o);
oos.close();
return Base64.getEncoder().encodeToString(baos.toByteArray());
// return Base64.getEncoder().encodeToString(baos.toByteArray());

return DatatypeConverter.printBase64Binary(baos.toByteArray());
} catch (IOException e) {
e.printStackTrace();
return "";
Expand Down

0 comments on commit a2e277e

Please sign in to comment.