Originally Posted by
aznprdgy
ah sorry no
the values have to actually be separate not just appear so that wont work. I need it so that each individual line can be assigned to a String or int variable.
How about this?
import java.util.Scanner;
import java.io.*;
public class driver {
public static int one, two, three, four, five, six, seven, eight, nine, ten;
public static int one2, two2, three2, four2, five2, six2, seven2, eight2, nine2, ten2;
public static String zombies, assassins;
public static void main(String[] args) throws Exception {
File script = new File("scripts.dat");
Scanner s1 = new Scanner(script);
String script1 = s1.next();
String script2 = s1.next();
assassins = script1 + " " + script2;
System.out.println(assassins);
one = s1.nextInt();
two = s1.nextInt();
three = s1.nextInt();
four = s1.nextInt();
five = s1.nextInt();
six = s1.nextInt();
seven = s1.nextInt();
eight = s1.nextInt();
nine = s1.nextInt();
ten = s1.nextInt();
System.out.println(one + "\n" + two + "\n" + three + "\n" + four + "\n"
+ five + "\n" + six + "\n" + seven + "\n" + eight + "\n" + nine
+ "\n" + ten);
String script3 = s1.next();
String script4 = s1.next();
zombies = script3 + " " + script4;
System.out.println(zombies);
one2 = s1.nextInt();
two2 = s1.nextInt();
three2 = s1.nextInt();
four2 = s1.nextInt();
five2 = s1.nextInt();
six2 = s1.nextInt();
seven2 = s1.nextInt();
eight2 = s1.nextInt();
nine2 = s1.nextInt();
ten2 = s1.nextInt();
System.out.println(one2 + "\n" + two2 + "\n" + three2 + "\n" + four2
+ "\n" + five2 + "\n" + six2 + "\n" + seven2 + "\n" + eight2
+ "\n" + nine2 + "\n" + ten2);
}
}
This now creates 2 Strings - 'zombies' & 'assasins'
And all the Integer values for the first section are stored as 'one', 'two', 'three', 'four', etc...
All the Integer values for the second section are stored as 'one2', 'two2', 'three2', 'four2', etc...
You can now call these variables from anywhere in your code.