This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Write a new Line Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Write a new Line" Watch "Write a new Line" New topic

Write a new Line

sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1073
i wrote a bello file.but it writ all things into one to remove it.

public static void main(String [] args) {

File file =new File("F:\\name.txt");
FileReader fr =new FileReader(file);
BufferedReader br =new BufferedReader(fr);
File file2 = new File("E:\\ana\\write.txt");
FileWriter fw =new FileWriter(file2);

String size = br.readLine();

System.out.println("br.readLine(); "+size);


}catch(IOException e)
Ankit Garg

Joined: Aug 03, 2008
Posts: 9291

Is this related to EJB or is it a Java-General-beginner question??

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 9962


[My Blog] [JavaRanch Journal]
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41182
" fw.write("\\n") " should read fw.write("\n") ", otherwise you're printing a backslash and an "n".

But using "\n" for newline is platform-specific for Unix/Linux; is that what you're using? For Windows, it'd be "\r\n". Or you could use a BufferedWriter that has a "newLine" method.

Ping & DNS - my free Android networking tools app
It is sorta covered in the JavaRanch Style Guide.
subject: Write a new Line
Similar Threads
Why no output is given here
File not found exception
Writing to File
FileReader and FileWriter
Create .txt file