Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- // ---------------------------------------------------------------------------------
- // Formatos:
- //
- // Unix 10 'NewLine'
- // DOS 13 10 'Carriage Return' 'NewLine'
- // ---------------------------------------------------------------------------------
- public class Unix2Dos {
- public static void convierte(String origen, String destino) {
- InputStream is;
- OutputStream os;
- int charTmp;
- try {
- is = new FileInputStream(origen);
- os = new FileOutputStream(destino);
- charTmp = is.read();
- //Recorre el input stream, reemplazando CR por CR+LF
- while (charTmp != -1) {
- //Si es un CR, escribe un LF
- if (charTmp == 10)
- os.write((int)13);
- os.write(charTmp);
- //Lee el siguiente caracter...
- charTmp = is.read();
- }
- os.flush();
- os.close();
- is.close();
- }
- catch(Exception e) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement