zoukankan      html  css  js  c++  java
  • Java context replacing with BufferedReader & PrintWriter

     public boolean replacesFileHeader(String strFillFullPath)
        {
            
    boolean bFlag = false;
            
    try{
                    
                File infile 
    = new File(strFillFullPath);   
                BufferedReader in 
    = new BufferedReader(new InputStreamReader( new FileInputStream(infile)));   
                File outfile 
    = new File(infile + ".tmp");  
                PrintWriter out 
    = new PrintWriter(new BufferedWriter(   
                            
    new OutputStreamWriter(new FileOutputStream(outfile))));
                String reading;
            
                
    while ((reading = in.readLine()) != null
                {
                    
    if ((reading.contains("HEADER")) || (reading.contains("DONE")))
                    {
                        
    if (reading.contains("HEADER") )
                        {
                            out.println(
    "HEADER|GSTEST|***|***");
                        } 
    else {
                        
                            out.println(
    "TRAILER|***|DONE");
                        }
                    } 
    else {
                        out.println(reading);
                    }
                                   
                } 
                out.close();   
                in.close();   
                infile.delete();   
                outfile.renameTo(infile);
                
                    bFlag 
    = true;
                } 
    catch (Exception xe) {
                    logTestResult(
    "*Error:"false,xe.getLocalizedMessage());
                    bFlag 
    =  false;
                }
                
    return bFlag;
        }

    - Make people around you successful is the biggest contribution to ourselves. -

  • 相关阅读:
    vue 中按需引入 echarts
    [Vue warn]: Error in nextTick: "TypeError: Cannot read property 'init' of undefined"
    js计算图片大小(promise)
    git push 提示'You are not allowed to push code to this project'
    echarts canvas 层级太高 导致tooltip被遮盖
    卡片展示(不定宽),最后一行左对齐 的几种实现方式
    styled-components 使用小结
    echarts 平均值及 y轴刻度n等分配置
    react 中使用阿里彩色图标
    php unlink()函数使用
  • 原文地址:https://www.cnblogs.com/zencorn/p/2093569.html
Copyright © 2011-2022 走看看