Java String Decode decode(String name)

Here you can find the source of decode(String name)

Description

decode

License

Apache License

Declaration

public static String decode(String name) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;

public class Main {
    public static String decode(String name) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < name.length(); i++) {
            char c = name.charAt(i);
            if (c != '_')
                sb.append(c);/*w w w . j  av a 2 s .  c  o  m*/
            else {
                c = (char) Integer.parseInt(name.substring(i + 1, i + 3), 16);
                sb.append(c);
                i += 2;
            }
        }
        return sb.toString();
    }

    public static void append(File file, byte[] data) {
        try (FileOutputStream stream = new FileOutputStream(file, true)) {
            stream.write(data);
            stream.getChannel().force(true);
            stream.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static void write(File file, byte[] data) {
        try (FileOutputStream stream = new FileOutputStream(file)) {
            stream.write(data);
            stream.getChannel().force(true);
            stream.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. decode(String bytes)
  2. decode(String cipherText)
  3. decode(String in)
  4. decode(String s)
  5. decode(String s)
  6. decode(String s)
  7. decode(String s)