I need help for my Java Assigment , replacing string
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.
Code Java:
/**
*
*/
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);
}
}
}
}
}
Re: I need help for my Java Assigment , replacing string
Can you explain what the problem is? If you are getting errors, copy the full text and paste it here.
If the output is wrong, copy and paste here the output and explain what is wrong with it and show what the output should be.