Hello guys!
I'm trying to make sketch with simple function of word-wrap removal in txt files.
The following code reads, join strings, writes, but not as it needs:
I tried to make this additionally: when you give parameters how many old strings will be in 1 new - 5 or 10 old in 1 new string. Now the problem is: It writes to document only 2 new strings( last 7 joined old strings into 8th new), and new others it doesn't create. I am afraid I get confused because of "loops" and "may not have been initialized".
This i use when I make 7 strings in one new:
for(int i = 1; i < lines.length/7 ; i++) { ... }
Next code for removing array out of bound exception - so the last or first 7 strings must be empty(spaced once and wrapped).
for(int ii = 0; ii <lines.length-6 ; ii++) {
...
mystring = lines[ii] + lines[ii+1] + lines[ii+2] + lines[ii+3] + lines[ii+4] + lines[ii+5] + lines[ii+6];
... }
Full
Code:
String sevenStrings = new String();
String temp[];
String[] bigStrings;
String lines[] = loadStrings("loadsomefile.txt");
String[] neww= new String[lines.length/7];
for(int i = 1; i < lines.length/7 ; i++) {
String currentstring;
for(int ii = 0; ii <lines.length-6 ; ii++) {
currentstring = lines[ii];
String mystring;
mystring = lines[ii] + lines[ii+1] + lines[ii+2] + lines[ii+3] + lines[ii+4] + lines[ii+5] + lines[ii+6];
String[] SevenStrings = {
lines[i], lines[i+1], lines[i+2], lines[i+3], lines[i+4], lines[i+5], lines[i+6] };
temp = append(SevenStrings,mystring);
println(SevenStrings);
saveStrings("writesomefile.txt", temp);
}
}
Any ideas appreciated!!!