Link to home
Start Free TrialLog in
Avatar of ahfish22
ahfish22

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ahfish22
ahfish22

ASKER

\r solved the problem
writer.write(line + "\n"); to writer.write(line + "\r");

thanks
should be
writer.write(line + "\r\n");