Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package jds.test;
- import java.io.*;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * Author: VISTALL
- * Company: J Develop Station
- * Date: 20:07/06.11.2010
- */
- public class Decoder
- {
- private static class FileFilter implements java.io.FileFilter
- {
- @Override
- public boolean accept(File pathname)
- {
- return pathname.isDirectory() || pathname.getName().endsWith(".java");
- }
- }
- private static final FileFilter FILTER = new FileFilter();
- public static void main(String... arg) throws Exception
- {
- parse(new File("C:/Test"));
- }
- private static void parse(File d) throws Exception
- {
- for (File fileOrDir : d.listFiles(FILTER))
- {
- if(fileOrDir.isDirectory())
- parse(fileOrDir);
- else
- rewrite(fileOrDir);
- }
- }
- private static void rewrite(File f) throws Exception
- {
- InputStreamReader in = new InputStreamReader(new FileInputStream(f), "UTF-8");
- List<Integer> buf = new ArrayList<Integer>();
- int c;
- while ((c = in.read()) > 0)
- {
- buf.add(c);
- }
- in.close();
- OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(f), "cp1251");
- for (int t : buf)
- out.write(t);
- out.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement