bob leduc

Greenhorn
+ Follow
since Jan 20, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by bob leduc

I'm new to LDAP (sun Ldap) and I need to create a LDAP Factory class that I can use in my java application. Any help or comments would be really appreciated. Thanks.
21 years ago
The textarea wrap should be "physical".

Originally posted by Michael Zalewski:
Keep the user's input in a textarea.
But when you want to display it read-only, use something like
<textarea wrap="virtual" cols="30" rows="10" style="border:none" readonly>
Netscape 4 ignores the readonly attribute. But if you don't include name=, the fact that the user can type into the textarea doesn't have any effect.

21 years ago
<code>
import java.util.*;
public class WordFormatter {
public static String[] format(String paragraph, int length) {
ArrayList formatted = new ArrayList();
StringTokenizer st = new StringTokenizer(paragraph); String next = "";
while (
st.hasMoreTokens()) {
String line = next;
while (line.length() < 30) {
if (st.hasMoreTokens()) {
next = st.nextToken();
if ((line.length() + next.length()) > 30) {
break;
}
if (!line.equals("")) {
line += " ";
}
line += next; next = "";
} else {
break;
}
}
formatted.add(line);
}
return (String[]) formatted.toArray(new String[0]);
}

public static void main(String[] args) {
String lines = "One feature of the war in Iraq was the speed and immediacy with which any events were reported by the media." + "Some of these turned out to be not quite what they seemed, others are still surrounded by confusion." + "Was this the fog of war, effects-based warfare, propaganda, or error?";
String[] formatted = WordFormatter.format(lines, 30);
for (int i = 0; i < formatted.length; i++) {
System.out.println(formatted[i]);
}
}
}
</code>
21 years ago
add this within your code:
try{
while (st.hasMoreTokens())
{
a=st.nextToken();
b=st.nextToken();
c=st.nextToken();
d=st.nextToken();
e=st.nextToken();
}
} catch (NoSuchElementException e){}
Hope this works?

Originally posted by dimps:
how can i use a string tokenizer in a loop.I need to read each line of a file and split it on a delimiter.
My txt file is in the format
A|B|C|D
i have used the following:
try
{
FileReader fr=new FileReader("myfile.txt");
BufferedReader br=new BufferedReader(fr);
while((line=br.readLine())!=null)
{
StringTokenizer st=new StringTokenizer(line,"|");
while (st.hasMoreTokens())
{
a=st.nextToken();
b=st.nextToken();
c=st.nextToken();
d=st.nextToken();
e=st.nextToken();
}
}
}catch(Exception ex){}
What happens is it reads one line then gives nosuchelementfound exception .can u suggest a way of gettin through this.Maybe i need to undefine st object at the end of the loop.If it is tht how do i undefine the object.

21 years ago
The functionality needed is as show below:
The original string:
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog again. The quick brown fox jumps over the lazy dog one more time.
The string word wrapped at 40 characters:
The quick brown fox jumps over the lazy
dog. The quick brown fox jumps over the
lazy dog again. The quick brown fox
jumps over the lazy dog one more time.

Originally posted by bob leduc:
I want to wrap at 15 characters without chumping the words.
Eg: hello, could anyone help? It would be really appreciated.
result: >hello, could_
>anyone help?__
>It would be_
>really_
>appreciated.
this (_) signifies an empty space
It would be greatly appreciated if you can show me an example. Thanks again!

21 years ago
I want to wrap at 15 characters without chumping the words.
Eg: hello, could anyone help? It would be really appreciated.
result: >hello, could_
>anyone help?__
>It would be_
>really_
>appreciated.
this (_) signifies an empty space
It would be greatly appreciated if you can show me an example. Thanks again!
21 years ago