I am reading data from text [utf8 format] file and store it in a string and convert that string into hexadecimal format and save this hexadecimal string into another file but I want to save this converted hexadecimal string line by line. How to do that?
String sCurrentLine;
br = new BufferedReader(new FileReader("demmo123.txt"));
while ((sCurrentLine = br.readLine()) != null) {
sb1.append(sCurrentLine);
}
String ss = sb1.toString();
Scanner sc = new Scanner(ss);
String helloWorldHex = toHexString(ss.getBytes());
file = new File("demmo.txt");
fop = new FileOutputStream(file);
if (!file.exists()) {
file.createNewFile();
}
byte[] contentInBytes = helloWorldHex.getBytes();
fop.write(helloWorldHex.getBytes());
fop.write(contentInBytes);
fop.flush();
fop.close();
fop.write(helloWorldHex.getBytes());