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

📄 splitmanywords.java

📁 一个简单的java程序
💻 JAVA
字号:
/*
  Written by: qa
  First written: 15/09/06
  Last modified: 15/09/06
*/

import sheffield.*;

public class SplitManyWords {
    public static void main(String[] args) {

	// open a file
	EasyReader file = new EasyReader("manywords.txt");

	// process line by line
	while (!file.eof()) {

	    // read a string
	    String s = file.readString();

	    // remove leading/trailing white spaces & place a space in the end
	    s = s.trim() + ' ';

	    // find the length of the string
	    int l = s.length();

	    // repeat until all spaces are processed
	    while (l>0) {

		// find the position of the first space
		int i = s.indexOf(' ');

		// identify the leading word and the rest of the string
		String w = s.substring(0, i);
		s = s.substring(i+1, l);

		// display words
		if (w.length()>0) {
		    System.out.println(w);
		}

		// find the length of the string
		l = s.length();
	    }
	}
    }
}

⌨️ 快捷键说明

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