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

📄 linereader.java

📁 All the tool for build a network able to reconize any shapes. Very complete, a good base for anythi
💻 JAVA
字号:
package neuralNetwork;
/*
Coded by Aydin Gurel, 2003
The code is free, but please contact me if you wish to use the code entirely or partially in any kind of project so that I can reference it and please don't delete these lines so that other people can reach this information. Also, please inform me if you encounter a bug.
aydingurel@hotmail.com
http://aydingurel.brinkster.com/neural
*/

import java.io.*;

// this class reads one line at a time and returns it as a string
public class LineReader
{
	String[] column;
	FileInputStream fis;
	BufferedInputStream bis;
	
	// constructor
	public LineReader (String path) {
		try {
			fis = new FileInputStream(path);
			bis = new BufferedInputStream(fis);
		}	      
		catch (IOException e) {}
		/*
		this.inputFile = new File(path);
		try {in = new FileReader(inputFile);} catch (IOException e) {}
		*/
	}

	// read the next line, split it and return the parts as a string array
	public boolean NextLineSplitted () {
		column = null;
		column = NextLine().split(";");
		if (column[0] != "#EOF#") {
			for (int i = 0; i < column.length; i++) {
				column[i] = column[i].trim();
			}
			return true;
		}
		else{return false;}
	}
	
	// read the next line, return the line as string
	public String NextLine() {
		int i;
		char[] temp_array = new char[50000];
		char[] temp_array2;
		boolean last_line;
		int counter;
		String temp_line = "";
		
		do {
			temp_array2 = null;
			counter = 0;
			last_line = true;
			// read a line
			try {
				while ( (i = bis.read()) != -1 ) {
					last_line = false;
					if (i == 13 || i == 10) {
						break;
					}
					else if( i != 10 && i != 13) {
						temp_array[counter++] = (char)i;
					}
				}
			}
			catch (IOException e) {}
			// put the array into a string
			if (last_line) {
				temp_line = "#EOF#";
			}
			else if (counter != 0) {
				temp_array2 = new char[counter];
				boolean all_spaces = true;
				for (int j = 0; j < counter; j++) {
					if (temp_array[j] != ' ') {all_spaces = false;}
					temp_array2[j] = temp_array[j];
				}
				if (all_spaces) {temp_line = "";}
				else {temp_line = new String(temp_array2);}
				if (temp_line.length() >= 2 && temp_line.charAt(0) == '/' && temp_line.charAt(1) == '/') {
					temp_line = "";
				}
			}
			else {
				temp_line = "";
			}

		} while (temp_line == "");
		return temp_line.trim();
	}
}

⌨️ 快捷键说明

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