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

📄 blank.java

📁 该程序是测试字符串用的
💻 JAVA
字号:
package com.dylan;

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;


public class Blank {
	
	
	public static String tool(String str) {
		int k1=-1,k2=-1;
		int i , j;
		for(i= 0 ; i<str.length() ;i++) {
			if(str.charAt(i)!= ' '){
				break;
			}
		}
		k1 = i;
		System.out.println(k1);
		for(j= str.length()-1 ; j>=0;j--) {
			if(str.charAt(j)!= ' '){
				break;
			}
		}
		k2 = j;
		System.out.println(k2);
		str = str.substring(k1,k2+1);
		System.out.println(str.hashCode());
		return str;
	}
	public static void main(String[]args)  {
		String str1="";
		DataInputStream dis = null;
		try {
			dis = new DataInputStream(new FileInputStream("C:\\test2.txt"));
			str1 = dis.readUTF();
		
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}finally {
			try {
				dis.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		System.out.println(str1.hashCode());
		str1 = tool(str1);
		System.out.println(str1.hashCode());
		System.out.println(str1);
		System.out.println(str1.length());
	}
}

⌨️ 快捷键说明

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