Класс MyPro



import java.util.zip.*;
import java.awt.*;
import java.io.*;
import javax.swing.*;

public class MyPro{
 public static String[] tt;
 public static String[] ext;
 public static String mtit,fn,npro;
 public static int isn,fs,fk;
 public static boolean ok;
 public static int[] ia = new int[4];
 public static ImageIcon aclic,aific,auic,batic,bmpic,datic,docic,exeic,gific,htmic,infic,iniic,jaric,
           javaic,jpgic,midic,mp3ic,paric,pdfic,pngic,pptic,psic,tific,txtic,wavic,wmaic,wmfic,zipic;

 public static void init(){
  aclic = new ImageIcon("data/aclIcon.png"); aific = new ImageIcon("data/aifIcon.png");
  auic  = new ImageIcon("data/auIcon.png");  batic = new ImageIcon("data/batIcon.png");
  bmpic = new ImageIcon("data/bmpIcon.png"); datic = new ImageIcon("data/datIcon.png");
  docic = new ImageIcon("data/docIcon.png"); exeic = new ImageIcon("data/exeIcon.png");
  gific = new ImageIcon("data/gifIcon.png"); htmic = new ImageIcon("data/htmIcon.png");
  infic = new ImageIcon("data/infIcon.png"); iniic = new ImageIcon("data/iniIcon.png");
  jaric = new ImageIcon("data/jarIcon.png"); javaic = new ImageIcon("data/javaIcon.png");
  jpgic = new ImageIcon("data/jpgIcon.png"); midic = new ImageIcon("data/midIcon.png");
  mp3ic = new ImageIcon("data/mp3Icon.png"); paric = new ImageIcon("data/parIcon.png");
  pdfic = new ImageIcon("data/pdfIcon.png"); pngic = new ImageIcon("data/pngIcon.png");
  pptic = new ImageIcon("data/pptIcon.png"); psic  = new ImageIcon("data/psIcon.png");
  tific = new ImageIcon("data/tifIcon.png"); txtic = new ImageIcon("data/txtIcon.png");
  wavic = new ImageIcon("data/wavIcon.png"); wmaic = new ImageIcon("data/wmaIcon.png");
  wmfic = new ImageIcon("data/wmfIcon.png"); zipic = new ImageIcon("data/zipIcon.png");
 }

 public static String readLine(String fn, int n){
  int i; String arg = " "; String ls = null; File fs = new File(fn);
  if( fs.exists() ){
   try{
    BufferedReader ins = new BufferedReader(new FileReader(fs));
    for( i=0; i < n; i++ ){ls = ins.readLine();} ins.close();
   }catch(IOException ex){ex.printStackTrace();}
  } if( ls != null ){arg=ls;}  
  return arg;
 }

 public static void writeLine(String args, String fn, int n){
  int i,im;  String eline = " "; String[] lines = new String[10000]; 
  File fs = new File(fn); String ls = null; i=0; im=0;
  if( fs.exists() ){
   try{
    BufferedReader ins = new BufferedReader(new FileReader(fs));
    while( (ls = ins.readLine()) != null && i < 10000 ){lines[i]=ls; i++;} ins.close();
   }catch(IOException ex){ex.printStackTrace();}
   im=i; 
  }
  if(n > im-1 && !ok){return;}
  try{
   PrintWriter out = new PrintWriter(new FileWriter(fs));
   if( n > 1 && n < 10001 ){
    for( i=0; i < n-1; i++ ){
     if( i < im ){out.println(lines[i]);}else{out.println(eline);}
   }}
   if( ok ){if(n == im){out.print(args);}else{out.println(args);}}
   if(n < im-1){ for( i=n; i < im-1; i++ ){ out.println(lines[i]); } }
   if(n < im){out.print(lines[im-1]);} 
   out.close();
  }catch(IOException ex){ex.printStackTrace();}
 }

 public static String[] split(String ls, char c){
  char[] p = ls.toCharArray(); int i,i1,i2,im,n; im=p.length; n=1;
  for( i=0; i < im; i++ ){if(p[i] == c){n++;}}
  String[] as = new String[n]; n=0; i1=0;
  for( i=0; i < im; i++ ){if(p[i] == c){i2=i-i1; as[n] = new String(p,i1,i2); i1=i+1; n++;}}
  if( i1 < im ){i2=im-i1; as[n] = new String(p,i1,i2);}else{as[n] = null;}
  return as;
 }

 public static Frame parent(){ int i,k,l;
  Frame[] frm = Frame.getFrames(); k=frm.length; l=-1;
  for(i=0; i < k; i++){if(frm[i].getTitle().equals(mtit)){l=i;}} 
  if(l != -1){return frm[l];}else{return frm[0];}
 }

 public static int[] ttiarr(String tt, int n){
  String all = "0123456789";
  int[] ia = new int[n];  int i,iv,k,m,ltt; ltt=tt.length();
  for( i=0; i < n; i++ ){ia[i]=999999;} m=0;  
  for( k=0; k < n; k++ ){
   while( tt.substring(m,m+1).equals(" ") && m < ltt ){m++;}
   if( m == ltt ){return ia;} 
   i = all.indexOf(tt.substring(m,m+1)); iv=0;
   while( i*(9-i) >= 0 ){
    iv=10*iv+i; m++; if( m == ltt ){break;}
    i=all.indexOf(tt.substring(m,m+1));
   } ia[k]=iv;
  } return ia;
 }

 public static String getExt(File f){
  String ext = null; String ls = f.getName();  int i = ls.lastIndexOf('.');
  if (i > 0 &&  i < ls.length()-1) {ext = ls.substring(i+1).toLowerCase();}
  return ext;
 }

 public static String zipcat(String fn){
  String cat; StringBuffer sb = new StringBuffer(); int n;
  try {
   ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(fn)));
   ZipEntry entry;
   while( (entry = zis.getNextEntry()) != null ){
    cat = entry.getName(); sb=sb.append(cat+"|");
   } zis.close();
  }catch(Exception e){e.printStackTrace();} cat=sb.toString(); n=cat.length();
  return cat.substring(0,n-1);
 }

 public static void zipfold(String fnz, String[] fold){
  int i,k,m,n,nm; nm = fold.length; 
  try{
   FileOutputStream fout = new FileOutputStream(fnz);
   ZipOutputStream zout = new ZipOutputStream(fout);
   for( n=0; n < nm; n++ ){ 
    File fi = new File(fold[n]);
    if( fi.isDirectory() ){ String[] files = fi.list(); k=files.length;
     for(i=0; i < k; i++){ File fc = new File(fold[n]+"/"+files[i]);
      if( fc.exists() ){ ZipEntry ze = new ZipEntry(fold[n]+"/"+files[i]);
       zout.putNextEntry(ze); m=(int)fc.length(); byte[] by = new byte[m];
        DataInputStream din = new DataInputStream(new BufferedInputStream(new FileInputStream(fc)));
        din.readFully(by,0,m); din.close();
       zout.write(by,0,m); zout.closeEntry();
   }}}} zout.close();
  } catch(IOException ex){ex.printStackTrace();}
 }

 public static void unzipfold(String fnz, String fold, int mod){
  boolean ok,fe; int i,l; File dir = null;
  int BUFFER = 2048; String cat; 
  try{
   if( fold.equals("null") ){ok=true; fe=false;}
   else{fe=true; dir = new File(fold);
    if( dir.exists() ){if(mod == 2){return;}else{ok=true;}}else{ok=dir.mkdir();}}
   if( ok ){  
    if(mod == 1 && fe){dir.deleteOnExit();}
    BufferedOutputStream dest = null; ZipEntry entry;
    ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(fnz)));
    while( (entry = zis.getNextEntry()) != null ) {
     cat = entry.getName(); l=cat.length(); i=l-1; ok=false;
     while( i > 0 && !ok ){if(cat.substring(i,i+1).equals("/")){ok=true;}else{i--;}} 
     if( i == 0 ){ i=1;} if( i == l-1 ){ok=false;}
     if( ok && fe && cat.substring(0,i).equals(fold) || !ok && !fe ){
      int count;
      byte[] data = new byte[BUFFER]; File fn = new File(cat); 
      FileOutputStream fos = new FileOutputStream(fn);
      dest = new BufferedOutputStream(fos, BUFFER);
      while( (count = zis.read(data,0,BUFFER)) != -1 ) {dest.write(data,0,count);}
      dest.flush(); dest.close(); if(mod == 1){fn.deleteOnExit();}
    }} zis.close();
  }} catch(Exception e){e.printStackTrace();}
 }

 public static void zipfile(String fnz, String[] files){
  try{
   FileOutputStream fout = new FileOutputStream(fnz);
   ZipOutputStream zout = new ZipOutputStream(fout);
   int i,k,m; k=files.length;
   for(i=0; i < k; i++){ File fi = new File(files[i]);
    if( fi.exists() ){ ZipEntry ze = new ZipEntry(files[i]);
     zout.putNextEntry(ze); m=(int)fi.length(); byte[] by = new byte[m];
      DataInputStream din = new DataInputStream(new BufferedInputStream(new FileInputStream(fi)));
      din.readFully(by,0,m); din.close();
     zout.write(by,0,m); zout.closeEntry();
   }} zout.close();
  }catch(IOException ex){ex.printStackTrace();}
 }

 public static void unzipfile(String fnz, String flnm, int mod){
  boolean ok,fe; int i,l; File dir = null;
  int BUFFER = 2048; String cat,fold;
  dir = new File(flnm); if( mod == 2 && dir.exists() ){return;}
  try{
   l=flnm.length(); i=l-1; ok=false; fe=false;
   while( i > 0 && !ok ){if(flnm.substring(i,i+1).equals("/")){ok=true;}else{i--;}} 
   if( i == l-1 ){ ok=false;}
   if( ok ){fold=flnm.substring(0,i); dir = new File(fold);
    if( !dir.exists() ){fe=dir.mkdir();}else{fe=false;}
   } if(mod == 1 && fe){dir.deleteOnExit();}
   BufferedOutputStream dest = null; ZipEntry entry;
   ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(fnz)));
   while( (entry = zis.getNextEntry()) != null ){cat = entry.getName();
    if(cat.equals(flnm)){
     int count;
     byte[] data = new byte[BUFFER]; File fn = new File(cat); 
     FileOutputStream fos = new FileOutputStream(fn);
     dest = new BufferedOutputStream(fos, BUFFER);
     while( (count = zis.read(data,0,BUFFER)) != -1 ) {dest.write(data,0,count);}
     dest.flush(); dest.close(); if(mod == 1){fn.deleteOnExit();} break;
   }} zis.close();
  } catch(Exception e){e.printStackTrace();}
 }
}