• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1932
  • Last Modified:

convert unix file format to dos file format?

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
ahfish22
Asked:
ahfish22
  • 2
1 Solution
 
objectsCommented:
use dos eol characters \r\n
0
 
ahfish22Author Commented:
\r solved the problem
writer.write(line + "\n"); to writer.write(line + "\r");

thanks
0
 
ahfish22Author Commented:
should be
writer.write(line + "\r\n");
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now