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

📄 file_io.java

📁 用java编写的用蝶式算法实现的fft
💻 JAVA
字号:
package project;

import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;

public class File_IO {
	public void saveFile(String fileName, String text) throws IOException {
		BufferedWriter out = new BufferedWriter(new FileWriter(fileName));
		out.write(text);
		out.close();
	}
	
	public ArrayList<String> openFile(String filename) {
		RandomAccessFile in = null;
		try {
			in = new RandomAccessFile(filename, "r");
		} catch (FileNotFoundException e) {
			System.out.println(e.toString());
			System.out.println("   No found the file you want!");
			System.exit(0);
		}
		String s1;
		s1 = "";
		ArrayList<String> data = new ArrayList<String>();
		try {
			while ((s1 = in.readLine()) != null) {
				data.add(s1);
			}
		} catch (IOException e) {
			System.out.println(e.toString());
			System.out.println("IO Error!");
			System.exit(0);
		}
		return data;
	}

	public int[] StringToInteger(char[] token, String str) {
		ArrayList<String> tstr = new ArrayList<String>();
		char[] ch = new char[str.length()];
		ch = str.toCharArray();
		int marker = 0;
		int postion = 0;
		for (int i = 0; i < str.length(); i++) {
			for (int j = 0; j < token.length; j++) {
				if (ch[i] == token[j]) {
					tstr.add(str.substring(marker, i));
					marker = i + 1;
					postion++;
				}
			}
		}
		tstr.add(str.substring(marker, str.length()));
		tstr.remove("");
		int[] p = new int[tstr.size()];
		for (int i = 0; i < p.length; i++) {
			p[i] = Integer.parseInt((String) tstr.get(i));
		}
		return p;
	}
}

⌨️ 快捷键说明

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