| 9 | import java.util.Base64; |
| 10 | |
| 11 | public class ClassToBase64 { |
| 12 | public static void main(String[] args) throws IllegalAccessException, IOException, InstantiationException { |
| 13 | String s = fileToBase64("/xx/classes/TestInterceptor.class"); |
| 14 | } |
| 15 | public static String fileToBase64(String filePath) throws IOException, IllegalAccessException, InstantiationException { |
| 16 | File file = new File(filePath); |
| 17 | FileInputStream inputFile = new FileInputStream(file); |
| 18 | byte[] buffer = new byte[(int) file.length()]; |
| 19 | inputFile.read(buffer); |
| 20 | inputFile.close(); |
| 21 | byte[] bs = Base64.getEncoder().encode(buffer); |
| 22 | System.out.println(new String(bs)); |
| 23 | return new String(bs); |
| 24 | } |
| 25 | |
| 26 | private static String classToBcel(String classFileName) throws IOException { |
| 27 | Path path = Paths.get(classFileName); |
| 28 | byte[] bytes = Files.readAllBytes(path); |
| 29 | String result = Utility.encode(bytes,true); |
| 30 | return "$$BCEL$$" + result; |
| 31 | } |
| 32 | |
| 33 | } |
nothing calls this directly
no outgoing calls
no test coverage detected