help me to save file with io
i make a java program that type code on frame . who compaile or run our code on frame output is transfer to our textArea . but when i trasfer that code to a file for save it from io. it save sucessfully but new line is not in my program . every think in single line . what i do help me
here is my code
Code Java:
file=new File("C:/vijay");
System.out.println("documentry created :- "+file.mkdir());
try
{
file=File.createTempFile("JavaApplication",".java" ,file);
fos=new FileOutputStream(file);
dos=new DataOutputStream(fos);
String demo=jta1.getText();
String demo1[]=demo.split("\n");
System.out.println(/*demo1[0]+*/" :- "+ch);
/*dos.writeUTF(demo);
DataInputStream dis=new DataInputStream(new FileInputStream(file));
String s=dis.readUTF();
System.out.println(s);
jta1.setText(s);*/
byte b[]=demo.getBytes();
dos.write(b);
}catch(Exception e) {System.out.println(e);}
i used so many method of DataOutputStream and FileOutputStream in io for do it.
Re: help me to save file with io
String demo1[]=demo.split("\n"); is removing your new line characters. Either stop removing them or put them back in.
System.out.println(/*demo1[0]+*/" :- "+ch); Where is the variable ch defined? Please be sure to include all relevant code when posting.
Re: help me to save file with io
bro its not working . if it worked then why i post it here . when i use this method all string is transfer to demo1[0] and null in the next string . any other method bro which is not in my program or toll me whats the mistake i am doing here ? and sorry for ch . it in the double cortestion like "ch" . help me pls
Re: help me to save file with io
all that method in that program are not working . i checked
Re: help me to save file with io
Quote:
Originally Posted by
vijay1807
bro its not working . if it worked then why i post it here . when i use this method all string is transfer to demo1[0] and null in the next string . any other method bro which is not in my program or toll me whats the mistake i am doing here ? and sorry for ch . it in the double cortestion like "ch" . help me pls
I didn't give you the code to use. I told you what your code is doing and gave you a link to the method you are using. That method is removing your new line character. -Either stop removing it, or figure out a way to put it back in.