Code to read from a file and then putting it into a constructor won't work

I'm a college student and I have a project in java and I'm trying to read from files and putting them into a constructor. The file i'm trying to read from is in this form: 2 Sciense [mr ali hassan 14/4/1993 ] Ali Hhassan 13234 12/3/1998 123 1234567891234 1234567891 engineer 2 Sciense [mr ali hassan 14/4/1993 ] Ali Hhassan 13234 12/3/1998 123 1234567891234 1234567891 null . . . e

从文件中读取代码然后将其放入构造函数中的代码将不起作用

我是一名大学生,我在java中有一个项目,我试图从文件中读取并将它们放入构造函数中。 我试图读取的文件是这种形式: 2 Sciense [mr ali hassan 14/4/1993 ] Ali Hhassan 13234 12/3/1998 123 1234567891234 1234567891 engineer 2 Sciense [mr ali hassan 14/4/1993 ] Ali Hhassan 13234 12/3/1998 123 1234567891234 1234567891 null . . . etc 我试图从标记中读取标记中的标记,并将它们放在我的构造函数中。 这是我

Scanner is skipping nextLine() after using next() or nextFoo()?

I am using the Scanner methods nextInt() and nextLine() for reading input. It looks like this: System.out.println("Enter numerical value"); int option; option = input.nextInt(); // Read numerical value from input System.out.println("Enter 1st string"); String string1 = input.nextLine(); // Read 1st string (this is skipped) System.out.println("Enter 2nd string"); String string2 = input.nex

扫描仪使用next()或nextFoo()后跳过nextLine()?

我正在使用Scanner方法nextInt()和nextLine()来读取输入。 它看起来像这样: System.out.println("Enter numerical value"); int option; option = input.nextInt(); // Read numerical value from input System.out.println("Enter 1st string"); String string1 = input.nextLine(); // Read 1st string (this is skipped) System.out.println("Enter 2nd string"); String string2 = input.nextLine(); // Read 2nd st

Scanner nextline() only printing new lines

I'm trying to use scanner to print lines from a text file, but it only prints first line before printing only new lines until while loop goes through file. String line; File input = new File("text.txt"); Scanner scan = new Scanner(input); while (scan.hasNext()) //also does not work with hasNextLine(), but additional error { line = scan.nextLine(); System.out.println(line); //other code can s

扫描仪nextline()仅打印新行

我试图使用扫描仪从文本文件中打印行,但它只打印第一行,然后才打印新行,直到while循环经过文件。 String line; File input = new File("text.txt"); Scanner scan = new Scanner(input); while (scan.hasNext()) //also does not work with hasNextLine(), but additional error { line = scan.nextLine(); System.out.println(line); //other code can see what is in the string line, but output from System.out.println(

Java scanner not going through entire file

I'm writing a program in Java and one of the things that I need to do is to create a set of every valid location for a shortest path problem. The locations are defined in a .txt file that follows a strict pattern (one entry per line, no extra whitespace) and is perfect for using .nextLine to get the data. My problem is that 241 lines into the file (out of 432) the scanner stops working 3/4

Java扫描程序不通过整个文件

我正在用Java编写一个程序,我需要做的一件事是为最短路径问题创建一组每个有效位置。 这些位置是在.txt文件中定义的,该文件遵循严格的模式(每行一个条目,没有额外的空格),并且非常适合使用.nextLine获取数据。 我的问题是,241行文件(432)中的扫描仪停止工作3/4通过一个条目的方式,并不承认任何新行。 我的代码: //initialize state space private static Set<String> posible(String posLoc) throws Fi

Running a Java program with input from a file

I am writing a program that reads the input from a file and then prints it to the screen. When I run it without taking the input from the file, it works perfectly fine. However, every time I try to run it from the file it gives me an "Exception in thread "main" java.util.NoSuchElementException: No line found at" error that occurs every place the input is suppose to be read.

使用文件输入运行Java程序

我正在编写一个程序,用于从文件中读取输入,然后将其输出到屏幕上。 当我运行它而没有从文件输入时,它工作得很好。 但是,每次我尝试从文件运行它时,它都会给我一个“线程中的异常”主“java.util.NoSuchElementException:没有找到线”的错误,该错误发生在每个要输入的地方。 我不知道发生了什么事。 该程序假设从用户处获得输入,创建一个Photo对象,然后将信息打印到屏幕上。 当我手动输入信息时,一切正常,但当我尝试

Any good ORM tools for Android development?

Anyone working on the Android ('gPhone') have or know of a place where I can find a good ORM tool for it? The code is written in Java, and the database is SQLite. What I would like to find is a tool that given the object definition, can auto-generate the tables and the CRUD functions (that would be awesome), or, barring that, a tool that can take the table definition, the object definit

用于Android开发的任何好的ORM工具?

任何在Android上工作的人('gPhone')是否知道我可以找到一个好的ORM工具? 代码是用Java编写的,数据库是SQLite。 我想找到的是一个给定对象定义的工具,它可以自动生成表格和CRUD函数(这很棒),或者,除此之外,可以使用表格定义,对象定义,并自动生成CRUD功能。 问题在于,所有这些都必须在Android框架内发生,Android框架对数据库访问的工作方式有自己的约定。 这个线程可能会给你一些探索:Hibernate的轻量级

Fastest way to copy one array list to another

I came across a question related to ArrayList of java in a company written test. My query is just a small part of the actual question. Lets say we have the following function to copy one ArrayList to another: void function(List<E> l) { List<E> m = new ArrayList<E>(l); } The question basically asks to optimize this copy operation. The List may contain a million entries.

将一个数组列表复制到另一个列表的最快方法

在公司书面测试中,我遇到了一个与java的ArrayList有关的问题。 我的查询只是实际问题的一小部分。 比方说,我们有以下功能将一个ArrayList复制到另一个: void function(List<E> l) { List<E> m = new ArrayList<E>(l); } 这个问题基本上要求优化这个复制操作。 该列表可能包含一百万个条目。 我尝试了以下方法: Collections.copy System.Arraycopy 全部添加 但所有这些似乎都比给定的方

Guice TypeListener not notified about the injected class Type

I have the following Guice module: class MyModule extends AbstractModule { @Override protected void configure() { bindListener(Matchers.any(), new TypeListener() {...}); } @Provides SomeClass createSomeClass(final Parameter param) { log(param.getValue()); <-- this gets logged ... } } What I found strange is that my TypeListener doesn'

Guice TypeListener没有通知注入的类类型

我有以下Guice模块: class MyModule extends AbstractModule { @Override protected void configure() { bindListener(Matchers.any(), new TypeListener() {...}); } @Provides SomeClass createSomeClass(final Parameter param) { log(param.getValue()); <-- this gets logged ... } } 我发现奇怪的是,我的TypeListener没有得到有关Parameter类型的通知。 即

Is it possible to execute update query in android using JDBC driver

This question already has an answer here: How do I UPDATE from a SELECT in SQL Server? 27 answers You can connect to MySQL or any remote database from android but it is not recommended at all. The recommended way is to write a simple web service that connects your android app and database engine. You can use PHP (the simplest way) to write web service. Data will be sent to the database vi

是否有可能在Android中使用JDBC驱动程序执行更新查询

这个问题在这里已经有了答案: 如何从SQL Server中的SELECT进行更新? 27个答案 你可以连接到MySQL或从android的任何远程数据库,但它不建议。 推荐的方法是编写一个简单的Web服务来连接你的Android应用程序和数据库引擎。 您可以使用PHP(最简单的方法)编写Web服务。 数据将通过Web服务发送到数据库,并可以检索结果作为响应。

How to create a jabber/XMPP proxy/logging service?

I am working for a company that is using Google Chatback (anonymous chat with a support employee in my company's case) as the main chat service provider. This service uses the XMPP (formerly known as Jabber) protocol for sending and receiving messages. Our company has ten support employee accounts, and they are accessible through the chatback service we have used on our website. The emplo

如何创建jabber / XMPP代理/日志记录服务?

我正在为一家使用Google Chatback的公司工作(与我公司案例中的支持员工进行匿名聊天)作为主要的聊天服务提供商。 该服务使用XMPP(以前称为Jabber)协议来发送和接收消息。 我们公司有10个支持员工账户,他们可以通过我们在我们网站上使用的chatback服务访问。 员工使用Mac OSX和Windows以及不同操作系统上的不同客户端。 聊天功能也可以通过Android和iOS上的本机应用程序进行访问。 我们需要一个记录聊天会话的服务,