• IO流读取文件内容时,出现空格的问题(未找到原因)


    import java.io.File;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.util.Arrays;
    
    public class TestFileWriter {
    	public static void main(String[] args) throws IOException {
    		File i = new File("D:\Huang\123.txt");
    		FileReader r = new FileReader(i);
    		FileWriter w = new FileWriter("D:\Huang\abcd.txt");
    		StringBuilder sb = new StringBuilder();
    		int b = -1;
    		char[] cs = new char[(int) i.length()];
    		int num = 0;
    		System.out.println(i.length());
    		while ((b = r.read(cs)) != -1) {
    			sb.append(cs);
    			System.out.println((num++) + Arrays.toString(cs));
    			System.out.println((num++) + String.valueOf(cs));//打印输出时   会输出空格
    		}
    		w.write(sb.toString());
    		w.flush();
    		r.close();
    		w.close();
    
    	}
    

      

  • 相关阅读:
    gitlab CI
    arm模拟环境qemustatic
    golang 离线使用模块
    企业微信机器人推送消息
    贴片丝印对照
    Air32F103CBT6
    RTT F411CE
    STM32F411CEU6
    CMakeLists.txt使用
    websocket测试(nodered)
  • 原文地址:https://www.cnblogs.com/1020182600HENG/p/6738177.html
Copyright © 2020-2023  润新知