1 package io.homework; 2 3 import java.io.FileReader; 4 import java.io.FileWriter; 5 import java.io.Reader; 6 import java.io.Writer; 7 8 public class q18 { 9 public static void main(String[] args) { 10 try(Reader fr = new FileReader("c.txt"); 11 Writer fw = new FileWriter("d.txt")) { 12 int[] arr = new int[26]; 13 while (true) { 14 int len = fr.read(); 15 if (len == -1) break; 16 arr[len - 'a']++; 17 if (arr[len - 'a'] > 1) { 18 continue; 19 } 20 fw.write((char)len); 21 } 22 } catch (Exception e) { 23 e.printStackTrace(); 24 } 25 } 26 }
标签:文件,java,len,io,import,根目录,txt From: https://www.cnblogs.com/zuamagee/p/17300438.html