I have a String array in Java (Using the NetBeans IDE) containing a small text. When inserting the lines of text into the array I ended up with too much unnecessary space and characters which I would like to get rid of. Here is an example:
1 experimental investigation of the aerodynamics of a wing in a slipstream . an experimental study of a wing [...] flow theory . an empirical [...] .
2 small viscosity . in the study of high-speed [...] vorticity . the discussion here is restricted to two-dimensional incompressible steady flow .
As you can see, in some cases I end up with 3 spaces between a period and the next word. How do I get rid of the extra space and characters such as periods, commas, etc?
Edit: Here is the process.
-Inserting the text on x position within the String array:
try{
coleccion = new File (File location);
fr = new FileReader (coleccion);
br = new BufferedReader(fr);
String numDoc = " ";
int pos = 0;
while((numDoc=br.readLine())!=null){
if(numDoc.contains(".W")){
while((numDoc=br.readLine())!= null && !numDoc.contains(".I")){
if(Text[pos] != null) {
Text[pos] = Texto[pos] + " " + numDoc;s
}
else {
Text[pos] = numDoc;
}
}
pos++;
}
}
}
catch(Exception e){
e.printStackTrace();
}
-Printing the array (1400 positions):
for(int i=0; i<=1399; i++){
//System.out.println(ID[i]);
System.out.println(i+1 + " " + Texto[i]);
}
-Extra info on the initial problem: .txt file to arrays using Java