Commit c2c4fcc4393be1d5b660b80b4e0af023d833e2da

Authored by Warunya Wongsawat
1 parent f98dd078
Exists in master

no message

genT4/.classpath 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<classpath>
  3 + <classpathentry kind="src" path="src"/>
  4 + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
  5 + <classpathentry kind="output" path="bin"/>
  6 +</classpath>
... ...
genT4/.project 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<projectDescription>
  3 + <name>genT4</name>
  4 + <comment></comment>
  5 + <projects>
  6 + </projects>
  7 + <buildSpec>
  8 + <buildCommand>
  9 + <name>org.eclipse.jdt.core.javabuilder</name>
  10 + <arguments>
  11 + </arguments>
  12 + </buildCommand>
  13 + </buildSpec>
  14 + <natures>
  15 + <nature>org.eclipse.jdt.core.javanature</nature>
  16 + </natures>
  17 +</projectDescription>
... ...
genT4/.settings/org.eclipse.jdt.core.prefs 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +eclipse.preferences.version=1
  2 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
  3 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
  4 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
  5 +org.eclipse.jdt.core.compiler.compliance=1.6
  6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate
  7 +org.eclipse.jdt.core.compiler.debug.localVariable=generate
  8 +org.eclipse.jdt.core.compiler.debug.sourceFile=generate
  9 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
  10 +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
  11 +org.eclipse.jdt.core.compiler.source=1.6
... ...
genT4/bin/genT4/genT4.class 0 → 100644
No preview for this file type
genT4/file.txt 0 → 100644
genT4/src/genT4/genT4.java 0 → 100644
... ... @@ -0,0 +1,81 @@
  1 +package genT4;
  2 +
  3 +import java.io.BufferedReader;
  4 +import java.io.BufferedWriter;
  5 +import java.io.File;
  6 +import java.io.FileReader;
  7 +import java.io.FileWriter;
  8 +import java.io.IOException;
  9 +
  10 +public class genT4 {
  11 +
  12 + public static void main(String[] args) throws IOException {
  13 + // TODO Auto-generated method stub
  14 +
  15 + String pathReadFile = "/Users/warunya/Desktop/test/newfile/";
  16 + String pathWriteFile = "/Users/warunya/Desktop/test/";
  17 +
  18 + directory(pathReadFile,pathWriteFile);
  19 +
  20 +
  21 + }
  22 + public static void directory(String path,String partwritefile) throws IOException {
  23 +
  24 + File directory = new File(path);
  25 +
  26 + //get all the files from a directory
  27 + File[] fList = directory.listFiles();
  28 +
  29 + for (File file : fList){
  30 + if(file.getName().contains(".java")){
  31 + readFile(path,file.getName(),partwritefile);
  32 + }
  33 +
  34 + }
  35 + }
  36 +
  37 + public static void readFile(String path,String filename,String partwritefile) throws IOException {
  38 + BufferedReader br = null;
  39 + try {
  40 + String sCurrentLine;
  41 + File file = new File(partwritefile + filename.replace(".java", ".txt"));
  42 + br = new BufferedReader(new FileReader(path+filename));
  43 +
  44 + // if file doesnt exists, then create it
  45 + if (!file.exists()) {
  46 + file.createNewFile();
  47 + }
  48 +
  49 + FileWriter fw = new FileWriter(file.getAbsoluteFile());
  50 + BufferedWriter bw = new BufferedWriter(fw);
  51 +
  52 + while ((sCurrentLine = br.readLine()) != null) {
  53 + if(sCurrentLine.contains("/// ###")){
  54 + sCurrentLine = sCurrentLine.replace("/// ", "");
  55 + System.out.println(sCurrentLine);
  56 + bw.write(sCurrentLine+"\n");
  57 + }else if (sCurrentLine.contains("/// * ####")){
  58 + sCurrentLine = sCurrentLine.trim();
  59 + sCurrentLine = sCurrentLine.replace("/// ", "");
  60 + System.out.println(sCurrentLine);
  61 + bw.write(sCurrentLine+"\n");
  62 + }else if (sCurrentLine.contains("/// *")){
  63 + sCurrentLine = sCurrentLine.replace("\t/// ", "");
  64 + System.out.println(sCurrentLine);
  65 + bw.write(sCurrentLine+"\n");
  66 + }
  67 + }
  68 + bw.close();
  69 +
  70 + } catch (IOException e) {
  71 + e.printStackTrace();
  72 + } finally {
  73 + try {
  74 + if (br != null)br.close();
  75 + } catch (IOException ex) {
  76 + ex.printStackTrace();
  77 + }
  78 + }
  79 + }
  80 +
  81 +}
... ...
genT4/test.txt 0 → 100644