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

📄 tools.java

📁 自己写的很独特的web服务器
💻 JAVA
字号:
package com.lblabs.tools;

import java.io.*;
import java.util.*;

public class Tools 
{
	int count;

	public void cp(String source, String target)
	{
		String str;
		try
		{
			BufferedReader br = new BufferedReader(new FileReader(source));
			BufferedWriter bw = new BufferedWriter(new FileWriter(target));

			while ((str = br.readLine()) != null)
			{
				bw.write(str + System.getProperty(("line.separator")));
			}
			bw.flush();
			br.close();
			bw.close();
		}
		catch (FileNotFoundException fnfe)
		{
			System.out.println(fnfe);
			return;
		}
		catch (IOException ioe)
		{
			System.out.println(ioe);
		}
	}

	public StringBuffer getTextFileBuffer(String fileName)
	{
		StringBuffer stringBuffer = new StringBuffer();
		String str = null;
		try
		{
			BufferedReader br = new BufferedReader(new FileReader(fileName));
			while ((str = br.readLine()) != null)
			{
				stringBuffer.append(str + System.getProperty("line.separator"));
			}
			br.close();
			return stringBuffer;
		}
		catch (FileNotFoundException fnfe)
		{
			System.out.println(fnfe);
			stringBuffer.append("Error");
			return stringBuffer;
		}
		catch (IOException ioe)
		{
			System.out.println(ioe);
			stringBuffer.append("Error");
			return stringBuffer;
		}
	}

	public String convertHashToString(Hashtable hashValue)
	{
		String strValue = "";
		Enumeration enum = hashValue.keys();
		while (enum.hasMoreElements())
		{
			
			strValue += (String)hashValue.get((String)enum.nextElement()) + "#";
			
		}
		return strValue;
	}
	
	public Hashtable convertStringToHash(String strValue)
	{
		int num = 0;
		int index = strValue.indexOf("#");
		Hashtable hashValue = new Hashtable();
		String str = null;
		while (index >= 0)
		{
			System.out.println(strValue.substring(0, index));
			hashValue.put(str.valueOf(num ++), strValue.substring(0, index));
			strValue = strValue.substring(index + 1);
			index = strValue.indexOf("#");
			System.out.println(strValue);
		}
		return hashValue;
	}
	
	public Hashtable convertURLStringToHash(String strValue)
	{
		int num = 0;
		int index=strValue.indexOf("?");
		int index1 = strValue.indexOf("=");
		int index2 = strValue.indexOf("&");
		
		Hashtable hashValue = new Hashtable();
		String str = null;
		while (index1 >= 0)
		{
			System.out.println(strValue.substring(index1+1, index2));
			hashValue.put(str.valueOf(num ++), strValue.substring(index1+1, index2));
			strValue = strValue.substring(index2 + 1);
			System.out.println(strValue);
			index1 = strValue.indexOf("=");
			index2 = strValue.indexOf("&");
		}
		return hashValue;
	}

	public String convertBooleanToString(boolean boolValue)
	{
		String str = null;
		return str.valueOf(boolValue);
	}

	public float convertStringToFloat(String floatStr)
	{
		Float bigFloat = new Float(floatStr);
		return bigFloat.floatValue();
	}

	public int convertStringToInt(String intStr)
	{
		Integer bigInt = new Integer(intStr);
		return bigInt.intValue();
	}

	public String convertIntToString(int intValue)
	{
		String str = null;
		return str.valueOf(intValue);
	}

	public String convertFloatToString(float floatValue)
	{
		String str = null;
		return str.valueOf(floatValue);
	}
}

⌨️ 快捷键说明

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