⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inifileio.java~5~

📁 这个是使用JAVA+JSP编写的聊天室源码
💻 JAVA~5~
字号:


/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

import java.io.*;
import java.net.*;

public class INIFileIO {
  File file;
  BufferedWriter bw;
  BufferedReader br;


  public INIFileIO(String path, boolean write) {
    try {
      file = new File(path);

      if (write) {
        bw = new BufferedWriter(new OutputStreamWriter(new
            FileOutputStream(file)));
      }
      else {
        br = new BufferedReader(new InputStreamReader(new
            FileInputStream(file)));
      }

    }
    catch (Exception e) {
      System.out.println(e.toString());
    }
  }

  public INIFileIO(String parent, String child, boolean write) {
    this(parent + "\\" + child, write);

  }

  public String converTo(int a) {

    switch ( (int) (Math.log(4) / Math.log(10))) {
      case 0:
        return "0000" + a;
      case 1:
        return "000" + a;
      case 2:
        return "00" + a;
      case 3:
        return "0" + a;
      case 4:
        return "" + a;

    }
    return null;

  }

  public String[][] read0() {
    try {
      String c = br.readLine();

      String[][] s = new String[new Integer(c.substring(1, 6)).intValue()][new
          Integer(c.substring(6, 11)).intValue()];
      br.readLine();
      for (int i = 0; i < s.length; i++) {
        for (int j = 0; j < s[0].length; j++) {
          s[i][j] = br.readLine();

        }
      }
      br.close();
      return s;
    }
    catch (Exception e) {
      System.out.println(e.toString());
      return null;
    }

  }

  public void write(String[][] s, String identifiers) {
    try {
      String str = "";
      bw.write("[" + converTo(s.length) + converTo(s[0].length) + "" + "]" +
               "\n\n");

      for (int i = 0; i < s.length; i++) {
        for (int j = 0; j < s[0].length; j++) {
          str = str + s[i][j] + "\n";
        }

      }

      bw.write(str);
      bw.flush();
      bw.close();
    }
    catch (Exception e) {
      System.out.println(e.toString());
    }

  }

 public void write(String s)
   {  try {
            bw.write(s);
            bw.flush();
            bw.close();
          }catch (Exception e) {
           System.out.println(e.toString());
         }
   }
   public String read()
   {  try {
     String c = br.readLine();
     br.close();
     return c;
     }catch (Exception e) {
      System.out.println(e.toString());
      return null;
    }

   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -