package Javaapplication 9;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Main{
public static void main(String[] args) throws FileNotFoundException {
Scanner scanner =
new Scanner(new File("C:/Users/F/Desktop/textfile.txt")).useDelimiter("\\Z"); /* z - failo pabaiga*/
String skaiciai = scanner.next();
System.out.print ("skaiciai yra: "); /* isvedam i ekrana uzrasa "skaiciai yra" */
System.out.println (skaiciai); /* isvedam skaicius, kurie yra faile*/
scanner.close();
}
}
Then, I need to sum numbers from that textfile.txt.. And I have no idea how to make a massive to sum them..
For example : in file numbers are 12156, sum of them is : 15..
This post has been edited by FUXAS: 06 March 2010 - 10:54 AM

New Topic/Question
Reply




MultiQuote








|