Hi , I have a assigment that was already due but I still want to work on it.
For this program im trying to replace every 4 words with with an astericks . It is suppose to be read from a file
and the line cannot exceed more than 80 characters.
So this what I have so far...
I'm also not allowed to use java codes that are off my level because I am new at this.
/** * */ package replace; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Scanner; public class replace { public static void main(String[] args) throws IOException { File file = new File ("input.txt"); Scanner inputFile= new Scanner(file); String input; String line; int StringLength; line=inputFile.nextLine(); //read first line for(int x=0;x<line;x++){ line=inputFile.nextLine();//read line StringLength=line.length(); //get length of string int y; while( y<StringLength){ if (input.charAt(y)isWhiteSpace); //save the characters before whitespace System.out.println(y); } } } } }