Solved

convert unix file format to dos file format?

Posted on 2004-10-10
3
1,681 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
javap not working 8 46
Running JavaFX on JDeveloper 12C 1 33
JavaFX TableView not displaying correctly 3 20
going to wrong jsp page 2 22
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

831 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