Example usage for com.liferay.portal.kernel.io OutputStreamWriter OutputStreamWriter

List of usage examples for com.liferay.portal.kernel.io OutputStreamWriter OutputStreamWriter

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.io OutputStreamWriter OutputStreamWriter.

Prototype

public OutputStreamWriter(OutputStream outputStream) 

Source Link

Usage

From source file:it.infn.ct.fratt.Fratt.java

License:Apache License

public String RemoveCarriageReturn(String InputFileName, String OutputFileName) {
    // Remove the carriage return char from a named file.                                
    FileInputStream fis;//from   w w w . j a  v  a 2 s  .  com
    try {

        fis = new FileInputStream(InputFileName);
        BufferedReader in = new BufferedReader(new InputStreamReader(fis));

        File fout = new File(OutputFileName);
        FileOutputStream fos = new FileOutputStream(fout);
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(fos));

        // The pattern matches control characters
        Pattern p = Pattern.compile("\r");
        Matcher m = p.matcher("");
        String aLine = null;

        try {
            while ((aLine = in.readLine()) != null) {
                m.reset(aLine);
                //Replaces control characters with an empty string.
                String result = m.replaceAll("");
                out.write(result);
                out.newLine();
            }
            out.close();
        } catch (IOException ex) {
            Logger.getLogger(Fratt.class.getName()).log(Level.SEVERE, null, ex);
        }

    } catch (FileNotFoundException ex) {
        Logger.getLogger(Fratt.class.getName()).log(Level.SEVERE, null, ex);
    }

    log.info("\n- Writing the user's stripped file: [ " + OutputFileName.toString() + " ] to disk");

    return OutputFileName;
}

From source file:it.infn.ct.iort.Iort.java

License:Apache License

public String RemoveCarriageReturn(String InputFileName, String OutputFileName) {
    // Remove the carriage return char from a named file.                                
    FileInputStream fis;/*from  w w w .j a  va2s.co m*/
    try {

        fis = new FileInputStream(InputFileName);
        BufferedReader in = new BufferedReader(new InputStreamReader(fis));

        File fout = new File(OutputFileName);
        FileOutputStream fos = new FileOutputStream(fout);
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(fos));

        // The pattern matches control characters
        Pattern p = Pattern.compile("\r");
        Matcher m = p.matcher("");
        String aLine = null;

        try {
            while ((aLine = in.readLine()) != null) {
                m.reset(aLine);
                //Replaces control characters with an empty string.
                String result = m.replaceAll("");
                out.write(result);
                out.newLine();
            }
            out.close();
        } catch (IOException ex) {
            Logger.getLogger(Iort.class.getName()).log(Level.SEVERE, null, ex);
        }

    } catch (FileNotFoundException ex) {
        Logger.getLogger(Iort.class.getName()).log(Level.SEVERE, null, ex);
    }

    log.info("\n- Writing the user's stripped file: [ " + OutputFileName.toString() + " ] to disk");

    return OutputFileName;
}

From source file:it.infn.ct.nuclemd.Nuclemd.java

License:Apache License

public String RemoveCarriageReturn(String InputFileName, String OutputFileName) {
    // Remove the carriage return char from a named file.                                
    FileInputStream fis;/*w  ww . j a  va2s . c  o  m*/
    try {

        fis = new FileInputStream(InputFileName);
        BufferedReader in = new BufferedReader(new InputStreamReader(fis));

        File fout = new File(OutputFileName);
        FileOutputStream fos = new FileOutputStream(fout);
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(fos));

        // The pattern matches control characters
        Pattern p = Pattern.compile("\r");
        Matcher m = p.matcher("");
        String aLine = null;

        try {
            while ((aLine = in.readLine()) != null) {
                m.reset(aLine);
                //Replaces control characters with an empty string.
                String result = m.replaceAll("");
                out.write(result);
                out.newLine();
            }
            out.close();
        } catch (IOException ex) {
            Logger.getLogger(Nuclemd.class.getName()).log(Level.SEVERE, null, ex);
        }

    } catch (FileNotFoundException ex) {
        Logger.getLogger(Nuclemd.class.getName()).log(Level.SEVERE, null, ex);
    }

    log.info("\n- Writing the user's stripped file: [ " + OutputFileName.toString() + " ] to disk");

    return OutputFileName;
}

From source file:it.infn.ct.trodan.Trodan.java

License:Apache License

public String RemoveCarriageReturn(String InputFileName, String OutputFileName) {
    // Remove the carriage return char from a named file.                                
    FileInputStream fis;/* w  ww .j  a  va 2 s .c  om*/
    try {

        fis = new FileInputStream(InputFileName);
        BufferedReader in = new BufferedReader(new InputStreamReader(fis));

        File fout = new File(OutputFileName);
        FileOutputStream fos = new FileOutputStream(fout);
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(fos));

        // The pattern matches control characters
        Pattern p = Pattern.compile("\r");
        Matcher m = p.matcher("");
        String aLine = null;

        try {
            while ((aLine = in.readLine()) != null) {
                m.reset(aLine);
                //Replaces control characters with an empty string.
                String result = m.replaceAll("");
                out.write(result);
                out.newLine();
            }
            out.close();
        } catch (IOException ex) {
            Logger.getLogger(Trodan.class.getName()).log(Level.SEVERE, null, ex);
        }

    } catch (FileNotFoundException ex) {
        Logger.getLogger(Trodan.class.getName()).log(Level.SEVERE, null, ex);
    }

    log.info("\n- Writing the user's stripped file: [ " + OutputFileName.toString() + " ] to disk");

    return OutputFileName;
}