计算机二级

3773考试网计算机等级考试计算机二级正文

完整操作ini文件的Java类

来源:fjzsksw.com 2010-7-19 14:53:26

 

public void myDodel(String section,String variable) throws Exception{

  int[] j = this.mySearch(section, variable);

  if (j[0] != -1) {

  if(!variable.equals("")){

  if (j[1] != -1) {

  this.inList.remove(j[1]);//删除一个节点

  }

  }else{

  int num=this.myGetNum(section);

  this.inList.remove(j[0]);

  for(int i=0;i

  this.inList.remove(j[0]);

  }

  }

  }

  }

  public String myGetOne(String section, String variable, String temp) {

  int[] j = this.mySearch(section, variable);

  if (j[0] != -1) {

  if (j[1] != -1) {

  if ((temp = this.outList.get(j[1]).toString().split("=")[1]) != "") {

  return temp;

  }

  }

  }

  return temp;

  }

  public String myGetOne(String section, String variable) { // 2 parameters;

  return this.myGetOne(section, variable, "?");

  }

  // end myGetOne();

  public void mySetOne(String section, String variable, String value){

  try{

  int[] j = this.mySearch(section, variable);

  if (j[0] != -1) {

  if (j[1] != -1) {

  this.inList.set(j[1], variable + "=" + value);

  } else {

  this.inList.add(j[0] + 1, variable + "=" + value);

  }

  } else {

  this.inList.add(this.inList.size(),"[" + section + "]" + "\r\n" + variable + "="

  + value);

  }

  }catch(Exception e){

  System.out.print(e);

  }

  } // end mySetOne();

  /*

  * 上边是对单行操作, 下边成批处理; @author Hongs(xhacker008)

  *

  * @version 2005.12.3

  */

  // myAdd();

  private void myAdd(String[] args) { // args = {section, variable [, value]};

  this.tagList.add(args);

  }

  public void myAdd(String section, String variable, String value) {

  String[] temp = { section, variable, value };

  this.myAdd(temp);

  }

  public void myAdd(String section, String variable) {

  String[] temp = { section, variable, "?" };

  this.myAdd(temp);

  }

  public void myAdd(String section, String[][] arr) { // arr[i] = {variable,

  // [, value]};

  int i = 0;

  String[] temp = new String[2];

  while (!arr[i][0].equals(null)) {

  for (int j = 0; j < 2; j++) {

  if (j == 0) {

  temp[j] = section;

  } else {

  temp[j] = arr[i][j - 1];

  }

  this.myAdd(temp);

  }

  i = i + 1;

  }

  }

 

上一页  [1] [2] [3] [4] 下一页

触屏版 电脑版
3773考试网 琼ICP备12003406号-1