package iso;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Test.Test1;
import objects.MessageBean;
@SuppressWarnings("serial")
public class ParseFile3 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
File file = new File("E:/mgronl.kkp");
InputStream in = new FileInputStream(file);
StringBuffer sb = new StringBuffer();
List list = new ArrayList();
List list1 = new ArrayList();
List list2 = new ArrayList();
List list3 = new ArrayList();
List list4 = new ArrayList();
String str = "";
BufferedReader br = new BufferedReader(new FileReader(file));
while ((str = br.readLine()) != null) {
list.add(str);
System.out.println(list.size());
sb.append(str+"%");
System.out.println(sb.toString());
String[] s = (sb.toString()).split("%");
} for(int i =0; i<list.size();i++){
if("[PACK]".equals(list.get(i)))
{ list1 = list.subList(i+1, list.size());
for(int m =0;m<list1.size();m++){
if(list1.get(m).toString().contains("FML")){
//String s = (list1.get(m).toString()).replaceAll(" ", "").substring(list1.get(m).toString().lastIndexOf("(")+1,list1.get(m).toString().indexOf(")")); String s=(list1.get(m).toString()).replaceAll(" ", "").substring((list1.get(m).toString()).replaceAll(" ", "").lastIndexOf("(")+1,(list1.get(m).toString()).replaceAll(" ", "").indexOf(")"));
list2.add(s);
for(int k=0;k<list2.size();k++){
System.out.println(list2.get(k));
}
}else if(list1.get(m).toString().contains("#")){
System.out.println(list1.get(m));
String s1 = list1.get(m).toString().substring(1, list1.get(m).toString().length());
list4.add(s1);
for(int k=0;k<list4.size();k++){
System.out.println(list4.get(k));
}
}
}
}
}
doPost(request, response,list2,list4);
}
public void doPost(HttpServletRequest request, HttpServletResponse response, List list2, List list4) throws ServletException, IOException {
response.setContentType("text/html; charset=utf-8");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the POST method"+"<br>");
for(int k=0;k<list2.size();k++){
System.out.println(list2.get(k));
out.println(list4.get(k)+":"+"<input name=list2.get(k) value=>"+"<br>");
}
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
public void init() throws ServletException { // Put your code here }
public static void main(String[] args) throws ServletException, IOException {
//String s=" =SADD (FML( RETURNMSG),)";
//s=s.replaceAll(" ", "").substring(s.replaceAll(" ", "").lastIndexOf("(")+1,s.replaceAll(" ", "").indexOf(")"));
//System.out.println(s);
ParseFile3 pf = new ParseFile3();
HttpServletRequest request = null;
HttpServletResponse response = null;
pf.doGet(request, response);
}
}