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

📄 readfromfile.java

📁 该内容是关于fdtd的源码,我用过,ok!不错!
💻 JAVA
字号:
/* 3D FDTD PACKAGE in Java by Stephen Kirkup
  ==========================================
  MARK 1. Released January 2005

  This file: readfromfile.java (part of the pre-processor) FDTDpre.java

  This is a shareware java source code that carries out the FDTD (finite difference time domain)
  algorithm. The code is available for general use. The copyright remains with the author; the
  program should not be passed on to others, even in revised form, without the permission of the
  author. The author would be pleased to hear of any interesting aplications of the code, ideas
  for future development, links to the website, or bugs in the code.

  The author can be contacted on smk@electromagnetics.info

  The webpages maintaining this code is www.fdtd.electromagnetics.info please refer to
  it for downloads or any news or updates.

  The java compiler/interpreter can be downloaded free from wwww.java.sun.com

  The FDTD algorithm is the most popular method for transient electromagnetic simulation.

  FDTD is also very computationally-intensive hence the program has been divided into two parts: a
  pre-processor (FDTDpre.java) that carries out the computation and stores relevant results and
  a post-processor (FDTDpost.java) that carries out a simple visualisation of the results.
  The test problem is input using the .DAT file and output to .OUT files. The .MON (monitor)
  file monitors the program (to be viewed soon after the start of the program to
  check that everything is as you expected and that the program will run in a reasonable time.

  */

import java.io.*;
public class readfromfile
{
	private static String file;
	private int irow,icol;

    public readfromfile(String fileName)
    {
		this.file=fileName;
    }

  public static String getFileName()
  {
	   return file;
  }


  public static String  get_string(int irow)
  {	int i;
	String s="";
	//Trap exceptions
	try
	{ BufferedReader in = new BufferedReader(new FileReader(file));
      for (i=1; i<=irow+1; i++) s=in.readLine();
	  in.close();
	}
	catch (FileNotFoundException e)
    { System.out.println("File not found:  " + file);
    }
   	catch (IOException e)
    { System.out.println("IOException: the stack trace is:");
    }
    return s;
  }

  public static double  get_double(int irow, int jcol)
  {	int i,j;
	String s="";
	double val=0.0;

	//Trap exceptions
	try
	{ BufferedReader in = new BufferedReader(new FileReader(file));
      StreamTokenizer st = new StreamTokenizer(in);
      for (i=1; i<=irow; i++) s=in.readLine();
      for (j=1; j<=jcol; j++) st.nextToken();
	  val=st.nval;
      in.close();
	}
	catch (FileNotFoundException e)
    { System.out.println("File not found:  " + file);
    }
   	catch (IOException e)
    { System.out.println("IOException: the stack trace is:");
    }
    return val;
  }

  public static int  get_int(int irow, int jcol)
  {	double val;
	int ival;
	val=get_double(irow,jcol);
	ival=(int)val;
	return ival;
  }

  public static boolean  get_boolean(int irow, int jcol)
  {	int ival;
	boolean x;
	ival=get_int(irow,jcol);
	x=true;
	if (ival!=1) x=false;
	return x;
  }

}

⌨️ 快捷键说明

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