I want to convert the text file into xml file.I have a large amount of string but i dont want to write in xml directly.
So that I have made a text file now i want to convert this
text file into xml format but when i am running this file getting no output. here is my
code:
public void convert() throws Exception {
String text[]=new String[10];
FileOutputStream fout = new FileOutputStream("res/values/mysml.xml");
OutputStreamWriter out = new OutputStreamWriter(fout);
InputStream in= getAssets().open("myText.txt");
Scanner scn = new Scanner(is);
for(int i=0;i<10;i++)
text[i]=bin.readLine();
out.write("<?xml version=\"1.0\"?>\r\n");
out.write("<resources>\r\n");
for (int i = 0; i < 10; i++){
out.write("<item>"+text[i]+"</item>");
}
out.write("</resources>");
out.flush();
out.close();
}
Try