import java.io.*; import java.util.Scanner; import java.util.Vector; public class test3 { public static void main(String[] args) throws IOException { int counter = 0; String line = null; // Location of file to read File file = new File("test.txt"); try { Scanner scanner = new Scanner(file); while (scanner.hasNextLine()) { line = scanner.nextLine(); System.out.println(line); //counter++; } scanner.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } //System.out.println(counter); } }
characters from file into an array...
assuming there are 4 arrays
array 0
array 1
array 2
array 3
and string is THISISASTRING or THIS IS A STRING
array 0 TITG
array 1 HSR
array 2 IAI
array 3 SSN
values to be input in such an order..
am unable to store the file string into a string currently for now.