Solved

convert unix file format to dos file format?

Posted on 2004-10-10
3
1,647 Views
Last Modified: 2012-05-05
File inputFile = new File("words.txt");
File outputFile = new File("wordsa.txt");

public void writeFile() throws IOException{

      BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile));
      BufferedReader reader = new BufferedReader(new FileReader(inputFile));

      String line=null;
   
         while((line = reader.readLine()) != null)
   
               {
      writer.write(line + "\n");
      System.out.println(line);
      }

      reader.close();
      writer.close();
}

im making a copy of the file for processing and saving it onto "wordsa.txt"
the file format of "wordsa.txt" is in UNIX. (i viewed it in ultraedit)
how can i edit the codes such that "wordsa.txt" will be saved in DOS file format without me converting it manually?
0
Comment
Question by:ahfish22
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 12273733
use dos eol characters \r\n
0
 

Author Comment

by:ahfish22
ID: 12273755
\r solved the problem
writer.write(line + "\n"); to writer.write(line + "\r");

thanks
0
 

Author Comment

by:ahfish22
ID: 12273759
should be
writer.write(line + "\r\n");
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
commonTwo  challenge 63 98
stringclean challenge 26 56
Core Java. What output will be and why ? 6 58
groovy example issue 10 66
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now