Here you can find the source of swap(byte[] bytes)
private static void swap(byte[] bytes)
//package com.java2s; public class Main { private static void swap(byte[] bytes) { int half = bytes.length / 2; for (int i = 0; i < half; i++) { byte temp = bytes[i]; bytes[i] = bytes[half + i];//from w w w . ja va2 s . c om bytes[half + i] = temp; } } public static String swap(String str) { char[] chars = str.toCharArray(); int half = chars.length / 2; for (int i = 0; i < half; i++) { char temp = chars[i]; chars[i] = chars[half + i]; chars[half + i] = temp; } return new String(chars); } }