Java编译pr渲染时错误编译影片:解析时已到文件结尾

Java编译时提示:进行语法解析时已到达文件结尾!这是为什么?
按时间排序
看看是不是少了大括号?
程序尾部少了个 }
,这个一定要注意了,{} 这符号是一对出现在程序里的
加上}之后运行结果是
做了点小修改:import java.io.BufferedRimport java.io.IOEimport java.io.InputStreamR@SuppressWarnings(&serial&)class Exception123 extends Exception { public String toString() {
return &由字符串123所引起的例外&; }}public class E1401 { public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
if (str.equals(&123&)){
throw new Exception123();
System.out.println(str);
} catch (Exception123 e) {
System.out.println(e.toString());
} finally {
System.out.println(&程序结束&);
} }}运行结果:123由字符串123所引起的例外程序结束
感谢您为社区的和谐贡献力量请选择举报类型
经过核实后将会做出处理感谢您为社区和谐做出贡献
确定要取消此次报名,退出该活动?
请输入私信内容:windows下进入cmd,输入&sqlcmd&回车。
restore database boss from disk = 'F:\boss1355.bak' with replace, move 'boss' to 'D:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\boss.mdf',move 'boss_log' to 'D:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\boss_log.ldf';
&go&,回车。
进行还原。
阅读(...) 评论()Java常见编译错误信息及说明_百度文库
赠送免券下载特权
10W篇文档免费专享
部分付费文档8折起
每天抽奖多种福利
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
Java常见编译错误信息及说明
&&关于Java变成过程中常出现的一些错误信息及说明
阅读已结束,下载本文需要
想免费下载本文?
定制HR最喜欢的简历
下载文档到电脑,同时保存到云知识,更方便管理
加入VIP
还剩5页未读,
定制HR最喜欢的简历
你可能喜欢进行语法解析时已到达文件结尾? - 知乎2被浏览<strong class="NumberBoard-itemValue" title="分享邀请回答//建立工程
package cn.edu.nwsuaf.qhs.artificialintelligence.eightpuzzle;
import java.util.Arrays;
public class EightPuzzle implements Cloneable{
/*利用一个二维的数组来存储数据*/
public int[][] data;
private int blankPos_x,blankPos_y;
private int depth;
//无参构造函数
public EightPuzzle(){
data = new int[3][3];
//传递一个数组,进行初始化的构造函数
public EightPuzzle(int [][] data){
this.data = data;
//判断是不是和目标位置相同
/*int[][] data1 = new int[][]{{1,2,3},{4,5,6},{7,8,9}};
int[][] data2 = new int[][]{{1,2,3},{4,5,6},{7,8,9}};
System.out.println("Equals---&"+Arrays.equals(data1, data2));
System.out.println("deepEquals---&"+Arrays.deepEquals(data1, data2));
public boolean isEquals(EightPuzzle ep){
return Arrays.deepEquals(this.data, ep.data);
public String toString(){
StringBuffer sb = new StringBuffer(20);
for (int i = 0; i & 3; i++){
for (int j = 0; j & 3; j++){
sb.append(this.data[i][j]);
sb.append(" ");
return sb.toString();
// 获取空格的位置
public void getPostion() {
for (int i = 0; i & 3; i++) {
for (int j = 0; j & 3; j++) {
if (this.data[i][j] == 0) {
this.setBlankPos_x(i);
this.setBlankPos_y(j);
public void setBlankPos_x(int blankPos_x) {
this.blankPos_x = blankPos_x;
public void setBlankPos_y(int blankPos_y) {
this.blankPos_y = blankPos_y;
public int getBlankPos_x() {
return blankPos_x;
public int getBlankPos_y() {
return blankPos_y;
public int getDepth() {
return depth;
public void setDepth(int depth) {
this.depth = depth;
public void print(){
System.out.println(this.toString());
protected EightPuzzle clone() throws CloneNotSupportedException {
// TODO Auto-generated method stub
return new EightPuzzle(Arrays.copyOf(this.data, this.data.length));
public EightPuzzle depthClone(){
EightPuzzle tmp_ep = new EightPuzzle();
for (int i = 0 ; i & 3; i++)
for (int j = 0 ; j & 3; j++)
tmp_ep.data[i][j] = this.data[i][j];
tmp_ep.depth = this.depth;
return tmp_ep;
public static void main(String[] args) {
public boolean equals(Object obj) {
// TODO Auto-generated method stub
return this.isEquals((EightPuzzle)obj);
//&&(this.getDepth() == ((EightPuzzle)obj).getDepth()
//第二个类
可以直接运行主函数()
package cn.edu.nwsuaf.qhs.artificialintelligence.eightpuzzle;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
public class EightPuzzleAlgorithm {
private int[][] array = new int[3][3];
private int[][] target = new int[3][3];
private EightPuzzle ep, target_ep;
private int depth = 0;
private Stack&EightPuzzle& ep_stack = new Stack&EightPuzzle&();
private LinkedList&EightPuzzle& searched_list = new LinkedList&EightPuzzle&();
private Queue&EightPuzzle& ep_queue = new LinkedList&EightPuzzle&();
public EightPuzzleAlgorithm() {
// 初始化栈和队列,以及列表
ep_stack.clear();
searched_list.clear();
ep_queue.clear();
Scanner scanner = new Scanner(System.in);
// 输入初始位置
System.out.println("请输入初始位置(其中输入0代表空白块,例如:2 8 3 1 0 4 7 6 5):");
for (int i = 0; i & 3; i++) {
for (int j = 0; j & 3; j++) {
array[i][j] = scanner.nextInt();
// 输入目标位置
System.out.println("请输入目标位置(其中输入0代表空白块,例如:2 8 3 1 4 0 7 6 5):");
for (int i = 0; i & 3; i++) {
for (int j = 0; j & 3; j++) {
target[i][j] = scanner.nextInt();
ep = new EightPuzzle(array);
ep.setDepth(depth);
// 设置栈底元素
ep_stack.push(ep);
target_ep = new EightPuzzle(target);
scanner.close();
// 设置队首元素
ep_queue.offer(ep);
// 深度优先搜索
// 栈的方式实现
public void depthFirstSearch() {
System.out.println("深度优先搜索方法路径!");
if (!searched_list.isEmpty())
searched_list.clear();
while (!ep_stack.isEmpty()) {
EightPuzzle move_ep = ep_stack.pop();
depth = move_ep.getDepth();
move_ep.getPostion();
int x = move_ep.getBlankPos_x(), y = move_ep.getBlankPos_y();
move_ep.print();
searched_list.add(move_ep);
if (move_ep.isEquals(target_ep)) {
System.out.println("终于找到了,⊙﹏⊙b汗");
EightPuzzle temp = null;
temp = move_ep.depthClone();
if (EightPuzzleOperator.canMove(x, y, 1)) {
temp = EightPuzzleOperator.movePosition(move_ep, 1);
temp.setDepth(depth);
if (!searched_list.contains(temp)) {
ep_stack.push(temp);
if (EightPuzzleOperator.canMove(x, y, 2)) {
temp = EightPuzzleOperator.movePosition(move_ep, 2);
temp.setDepth(depth);
if (!searched_list.contains(temp)) {
ep_stack.push(temp);
if (EightPuzzleOperator.canMove(x, y, -1)) {
temp = EightPuzzleOperator.movePosition(move_ep, -1);
temp.setDepth(depth);
if (!searched_list.contains(temp)) {
ep_stack.push(temp);
if (EightPuzzleOperator.canMove(x, y, -2)) {
temp = EightPuzzleOperator.movePosition(move_ep, -2);
temp.setDepth(depth);
if (!searched_list.contains(temp)) {
ep_stack.push(temp);
System.out.println("非常遗憾,没有搜索到你需要的目标!%&_&%");
// 深度优先搜索(有界,最大深度为5)
// 栈的方式实现搜索
public void boundedDepthFirstSearch() {
System.out.println("有界深度优先搜索方法路径!");
if (!searched_list.isEmpty())
searched_list.clear();
while (!ep_stack.isEmpty()) {
EightPuzzle move_ep = ep_stack.pop();
depth = move_ep.getDepth();
move_ep.getPostion();
int x = move_ep.getBlankPos_x(), y = move_ep.getBlankPos_y();
move_ep.print();
searched_list.add(move_ep);
if (move_ep.isEquals(target_ep)) {
System.out.println("终于找到了,⊙﹏⊙b汗");
if (depth & 4) {
EightPuzzle temp = null;
temp = move_ep.depthClone();
if (EightPuzzleOperator.canMove(x, y, 1)) {
temp = EightPuzzleOperator.movePosition(move_ep, 1);
temp.setDepth(depth);
if (!searched_list.contains(temp)||(searched_list.contains(temp)&&
searched_list.get(searched_list.indexOf(temp)).getDepth()!=temp.getDepth())) {
ep_stack.push(temp);
if (EightPuzzleOperator.canMove(x, y, 2)) {
temp = EightPuzzleOperator.movePosition(move_ep, 2);
temp.setDepth(depth);
if (!searched_list.contains(temp)||(searched_list.contains(temp)&&
searched_list.get(searched_list.indexOf(temp)).getDepth()!=temp.getDepth())) {
ep_stack.push(temp);
if (EightPuzzleOperator.canMove(x, y, -1)) {
temp = EightPuzzleOperator.movePosition(move_ep, -1);
temp.setDepth(depth);
if (!searched_list.contains(temp)||(searched_list.contains(temp)&&
searched_list.get(searched_list.indexOf(temp)).getDepth()!=temp.getDepth())) {
ep_stack.push(temp);
if (EightPuzzleOperator.canMove(x, y, -2)) {
temp = EightPuzzleOperator.movePosition(move_ep, -2);
temp.setDepth(depth);
if (!searched_list.contains(temp)||(searched_list.contains(temp)&&
searched_list.get(searched_list.indexOf(temp)).getDepth()!=temp.getDepth())) {
ep_stack.push(temp);
System.out.println("非常遗憾,没有搜索到你需要的目标!%&_&%");
// 宽度(广度)优先搜索实现
public void breadthFirstSearch() {
if (!searched_list.isEmpty())
searched_list.clear();
System.out.println("广度优先搜索方法路径!");
while (!ep_queue.isEmpty()) {
EightPuzzle move_ep = ep_queue.poll();
depth = move_ep.getDepth();
move_ep.getPostion();
int x = move_ep.getBlankPos_x(), y = move_ep.getBlankPos_y();
move_ep.print();
searched_list.add(move_ep);
if (move_ep.isEquals(target_ep)) {
System.out.println("终于找到了,⊙﹏⊙b汗");
EightPuzzle temp = null;
temp = move_ep.depthClone();
if (EightPuzzleOperator.canMove(x, y, 1)) {
temp = EightPuzzleOperator.movePosition(move_ep, 1);
temp.setDepth(depth);
if (!searched_list.contains(temp)) {
ep_queue.offer(temp);
if (EightPuzzleOperator.canMove(x, y, 2)) {
temp = EightPuzzleOperator.movePosition(move_ep, 2);
temp.setDepth(depth);
if (!searched_list.contains(temp)) {
ep_queue.offer(temp);
if (EightPuzzleOperator.canMove(x, y, -1)) {
temp = EightPuzzleOperator.movePosition(move_ep, -1);
temp.setDepth(depth);
if (!searched_list.contains(temp)) {
ep_queue.offer(temp);
if (EightPuzzleOperator.canMove(x, y, -2)) {
temp = EightPuzzleOperator.movePosition(move_ep, -2);
temp.setDepth(depth);
if (!searched_list.contains(temp)) {
ep_queue.offer(temp);
System.out.println("非常遗憾,没有搜索到你需要的目标!%&_&%");
/*public void search() {
// this.getPostion();
// this.depthFirstSearch(blankPos_x, blankPos_y, 1);
this.depthFirstSearch();
this.boundedDepthFirstSearch();
this.breadthFirstSearch();
* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
EightPuzzleAlgorithm epa = new EightPuzzleAlgorithm();
epa.depthFirstSearch();
epa.boundedDepthFirstSearch();
epa.breadthFirstSearch();
* 测试用例 【1】2 8 3 1 0 4 7 6 5 2 8 3 1 4 0 7 6 5 【2】2 8 3 1 0 4 7 6 5
//第三个类
package cn.edu.nwsuaf.qhs.artificialintelligence.eightpuzzle;
public class EightPuzzleOperator {
//判断是不是可以继续移动
public static boolean canMove(int x, int y, int direction) {
if ((direction == 1 && x == 0) || (direction == -1 && x == 2)
|| (direction == 2 && y == 2) || (direction == -2 && y == 0)) {
return false;
return true;
//根据给出的参数,进行空格位置的移动
//其中1表示向上,2表示向右,-1表示向下,-2表示向左
public static EightPuzzle movePosition(EightPuzzle ep, int args) {
EightPuzzle arg_ep = null;
arg_ep = ep.depthClone();
arg_ep.getPostion();
int blankPos_x = arg_ep.getBlankPos_x(), blankPos_y = arg_ep
.getBlankPos_y();
//指令为向上移动
if (args == 1) {
int temp = arg_ep.data[blankPos_x][blankPos_y];
arg_ep.data[blankPos_x][blankPos_y] = arg_ep.data[blankPos_x - 1][blankPos_y];
arg_ep.data[blankPos_x - 1][blankPos_y] = temp;
//表示移动成功
//指令为向下移动
else if (args == -1) {
int temp = arg_ep.data[blankPos_x][blankPos_y];
arg_ep.data[blankPos_x][blankPos_y] = arg_ep.data[blankPos_x + 1][blankPos_y];
arg_ep.data[blankPos_x + 1][blankPos_y] = temp;
//表示移动成功
//指令为向右移动
else if (args == 2) {
int temp = arg_ep.data[blankPos_x][blankPos_y];
arg_ep.data[blankPos_x][blankPos_y] = arg_ep.data[blankPos_x][blankPos_y + 1];
arg_ep.data[blankPos_x][blankPos_y + 1] = temp;
//表示移动成功
//指令为向左移动
else if (args == -2) {
int temp = arg_ep.data[blankPos_x][blankPos_y];
arg_ep.data[blankPos_x][blankPos_y] = arg_ep.data[blankPos_x][blankPos_y - 1];
arg_ep.data[blankPos_x][blankPos_y - 1] = temp;
//表示移动成功
//指令输入错误
return null;
return arg_ep;
0添加评论分享收藏感谢收起System.in);
// 输入初始位置
System.out.println("请输入初始位置(其中输入0代表空白块,例如:2 8 3 1 0 4 7 6 5):");
for (int i = 0; i & 3; i++) {
for (int j = 0; j & 3; j++) {
array[i][j] = scanner.nextInt();
// 输入目标位置
System.out.println("请输入目标位置(其中输入0代表空白块,例如:2 8 3 1 4 0 7 6 5):");
for (int i = 0; i & 3; i++) {
for (int j = 0; j & 3; j++) {
target[i][j] = scanner.nextInt();
ep = new EightPuzzle(array);
ep.setDepth(depth);
// 设置栈底元素
ep_stack.push(ep);
target_ep = new EightPuzzle(target);
scanner.close();
// 设置队首元素
ep_queue.offer(ep); } // 宽度(广度)优先搜索实现 public void breadthFirstSearch() {
if (!searched_list.isEmpty())
searched_list.clear();
System.out.println("广度优先搜索方法路径!");
while (!ep_queue.isEmpty()) {
EightPuzzle move_ep = ep_queue.poll();
depth = move_ep.getDepth();
move_ep.getPostion();
int x = move_ep.getBlankPos_x(), y = move_ep.getBlankPos_y();
move_ep.print();
searched_list.add(move_ep);
if (move_ep.isEquals(target_ep)) {
System.out.println("终于找到了,⊙﹏⊙b汗");
EightPuzzle temp =
temp = move_ep.depthClone();
if (EightPuzzleOperator.canMove(x, y, 1)) {
temp = EightPuzzleOperator.movePosition(move_ep, 1);
temp.setDepth(depth);
if (!searched_list.contains(temp)) {
ep_queue.offer(temp);
if (EightPuzzleOperator.canMove(x, y, 2)) {
temp = EightPuzzleOperator.movePosition(move_ep, 2);
temp.setDepth(depth);
if (!searched_list.contains(temp)) {
ep_queue.offer(temp);
if (EightPuzzleOperator.canMove(x, y, -1)) {
temp = EightPuzzleOperator.movePosition(move_ep, -1);
temp.setDepth(depth);
if (!searched_list.contains(temp)) {
ep_queue.offer(temp);
if (EightPuzzleOperator.canMove(x, y, -2)) {
temp = EightPuzzleOperator.movePosition(move_ep, -2);
temp.setDepth(depth);
if (!searched_list.contains(temp)) {
ep_queue.offer(temp);
System.out.println("非常遗憾,没有搜索到你需要的目标!%&_&%"); } /*public void search() {
// this.getPostion();
// this.depthFirstSearch(blankPos_x, blankPos_y, 1);
this.depthFirstSearch();
this.boundedDepthFirstSearch();
this.breadthFirstSearch(); }*/ /**
* @param args
*/ public static void main(String[] args) {
// TODO Auto-generated method stub
EightPuzzleAlgorithm epa = new EightPuzzleAlgorithm();
epa.breadthFirstSearch(); } /*
* 测试用例 【1】2 8 3 1 0 4 7 6 5 2 8 3 1 4 0 7 6 5 【2】2 8 3 1 0 4 7 6 5
*/0添加评论分享收藏感谢收起写回答JAVA中怎么判断已经读取到文件的末尾?
按时间排序
InputStream in = ......byte[] b = new byte[1024];while((i = in.read(b)) != -1) {
......}in.close();InputStream类的read(byte[])方法返回值为-1时表示到文件尾。
当读到文件末尾时将返回-1,例如:FileInputStream in=new FileInputStream(new File(&文件的路径和名称&));int c=0;if((c=in.read())==-1){
System.out.println(&文件已经读完&);}
DataInputStream in = new DataInputStream(fstream);
while (in.available() !=0){
文件的大小长度
while(in.readLine()!=null) {
读文件}in 是流对象
是用流读的么???什么类型的文件??文本?
感谢您为社区的和谐贡献力量请选择举报类型
经过核实后将会做出处理感谢您为社区和谐做出贡献
确定要取消此次报名,退出该活动?
请输入私信内容:}

我要回帖

更多关于 解析时已到达文件结尾 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信