/*広告*/
/*[簡易ソフト開発] ソースHTML置換Javaソース*/
import java.io.*; class CodeToHTML{ public static void main(String args[]){ String str = FileToString.fileToString(args[0]); if(!(str.equals("error"))){ System.out.println("置換前の内容"); System.out.println(str); str = str.replaceAll("&","&"); str = str.replaceAll("<","<"); str = str.replaceAll(">",">"); str = str.replaceAll("\"","""); System.out.println("\n置換後の内容"); System.out.println(str); System.out.println("\n置換してよろしいですか?(y / n)"); String ans; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try{ ans = br.readLine(); if(ans.equals("y")){ FileWriter fw = new FileWriter(new File(args[0])); fw.write(str); fw.close(); System.out.println("置換完了しました!"); } else{ System.out.println("置換中止しました!"); } } catch(IOException e){ System.out.println(e); } } } } class FileToString{ static String fileToString(String file_name){ StringBuffer sb = new StringBuffer(); try{ FileReader fr = new FileReader(new File(file_name)); int ch; while((ch = fr.read()) != -1){ sb.append((char)ch); } fr.close(); } catch(FileNotFoundException e){ System.out.println(e); return "error"; } catch(IOException e){ System.out.println(e); return "error"; } return sb.toString(); } }/*Copyright 2016 K.N/petitetech.com*/
/*広告*/