Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

convert unix file format to dos file format?

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
arguments to jar 5 35
How to determine if a string is a valid SHA value 7 35
Problem to Alipay 10 44
jsp error 6 26
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

828 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