Why do I have to write twice to add an input in the Arraylist?

public static void main(String[] args) { List arrayList = new ArrayList(); Scanner input = new Scanner(System.in); do { System.out.println(“Enter a …

Extraction of string and integer from txt

I’m trying to make a simple scanner reader to read from a txt stored in C:UsersjamesDesktopprojectfiles and it’s called data “data.txt”, the thing is that the information stored is …

Cant find pattern with Scanner in Java 8

I’m working with Java 8 on eclipse and trying to use regex to detect strings in a file, but I’m not detecting anything. I’ve tested the regex on its own and it successfully match’s strings in the file …

Java scanner.nextLine() not reading long line with 259094 characters

I want to read an xml file as a String in Java so that I can encrypt it. My current approach is to treat it like a txt file. My problem is that the third line in the xml file is 259094 characters long …

How to implement Body Mass Index (BMI)in Java

My problem is how can I implement without the Scanner method and with Math.round and Math.pow? Here is my code: import java.util.Scanner; public class BMI{ public static void main(String …

input arabic characters with scanner in maven project

i work on netbeans 8.2 and i create a java maven project, i want just take an input with arabic characters and display it and that don’t work properly : Scanner sc = new Scanner(System.in); …

How do I get the Scanner in java to read a string? [closed]

How would I get my program to quit when the user enters q? Is there something wrong with the scanner? My code import java.util.*; public class Main{ public static void main(String []args){ …

How to skip a leading string when scanning text file?

I’m making a program that draws a basic image using instructions from a text file. The format for the instructions is: SIZE 1000 500 // GROUND LINE 0 350 1000 350 LINE 0 351 1000 351 LINE 0 352 1000 …

Java exception [SWITCH && SCANNER]

I was trying to make my first java program with the use of switches and scanners, but I just can’t fix the error that returns me. Error: Exception in thread “main” java.util….

Why is the useDelimiter works like that?

I have been trying to read a folder that contains any text files like this: K.Love,CLE,miss,2 K.Leonard,TOR,miss,2 K.Love,CLE,make,1 … I was doing some tests and for some reason when I use the …