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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
should be
writer.write(line + "\r\n");
writer.write(line + "\r\n");
ASKER
writer.write(line + "\n"); to writer.write(line + "\r");
thanks