This simple program I wrote
To read the text from a text file Everything is fine, but when I read large text
The program does not read all the text
public class Testing {
public static void main(String[] args) throws InterruptedException {
System.out.print("Enter the path \".txt\" :");
Scanner inputPath = new Scanner(System.in);
String path =inputPath.nextLine();
System.out.print("Enter the speed of printing fromm (100-10000) :");
int speed=inputPath.nextInt();
try{
FileReader file = new FileReader(path);
String data = new Scanner(file).useDelimiter("\\z").next();
for(int i=0;i<data.length();i++){
System.out.print(String.valueOf(data.charAt(i)));
Thread.sleep(speed);
}
} //methode for save file path inside program
catch(FileNotFoundException x) {
JOptionPane.showMessageDialog(null, x);
}
}
}
I think the String variable can not save a large text. so what is the best way to solve this problem
I want to Read each text no matter how big