This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Java File Copy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java File Copy" Watch "Java File Copy" New topic

Java File Copy

Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492

I have one report file ex.rpt and am copying this file and saving it as new file called ex.txt. And then am sending it to printer and the alignment is bad.

Again I opened a new notepad and then copy the contents of the text file and paste it in the notepad manually and saving it as ex.txt then sending it to printer.

Its printing fine.

How can I copy the contents of the file to a new notepad file(.txt file)
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 917

your problem statement is abstract, maybe you could post your code snippet in here

I am guessing that your problem is due to non printable characters such as carriage return,form feed, tabs that you may get this issue

keep in mind that in windows newline consists of "\r\n" and not "\n"

Do one test, open same (output) file in notepad and wordpad and see if there is any difference in view in both, if yes, then the problem is
definately due to newline characters.
There is a method by which you can find out the system's newline char but i leave that to you to figure out.

My Website: [] Cool your mind:[] My Sally:[]
subject: Java File Copy
Similar Threads
Saving files in .txt format using JFileChooser.
how to write comma in CSV file
How to delete the file with space in name?
ctrlC ctrlV a war file contents
Printing API Question