1 package org.apache.axis2.wsdl.util; 2 3 import org.apache.axis2.wsdl.codegen.XSLTConstants; 4 5 import java.io.File ; 6 import java.io.IOException ; 7 8 25 public class FileWriter { 26 27 37 public static File createClassFile(File rootLocation,String packageName,String fileName,String extension) throws IOException ,Exception { 38 File returnFile = null; 39 File root = rootLocation; 40 41 if (packageName!=null){ 42 String directoryNames[] = packageName.split("\\."); 43 File tempFile = null; 44 int length = directoryNames.length; 45 for (int i = 0; i < length; i++) { 46 tempFile = new File (root,directoryNames[i]); 47 root = tempFile; 48 if (!tempFile.exists()){ 49 tempFile.mkdir(); 50 } 51 } 52 } 53 54 if (!fileName.endsWith(extension)){ 55 fileName = fileName + extension; 56 } 57 58 returnFile = new File (root,fileName); 59 60 if (!returnFile.exists()){ 61 returnFile.createNewFile(); 62 } 63 return returnFile; 64 } 65 66 77 public static File createClassFile(File rootLocation,String packageName,String fileName,int fileType) throws IOException ,Exception { 78 return createClassFile(rootLocation,packageName,fileName,getExtension(fileType)); 79 80 } 81 82 87 private static String getExtension(int fileType) { 88 String extension = ""; 89 switch (fileType){ 90 case XSLTConstants.LanguageTypes.JAVA: extension=".java";break; 91 case XSLTConstants.LanguageTypes.C_SHARP: extension=".cs";break; 92 case XSLTConstants.LanguageTypes.C_PLUS_PLUS: extension=".cpp";break; 93 case XSLTConstants.LanguageTypes.VB_DOT_NET: extension=".vb";break; 94 default: extension=".xml"; 95 } 96 return extension; 97 } 98 99 } 100 | Popular Tags |