This is probably not your bottleneck, but you could achieve the same result by:
- ditching the
StringTokenizer
in favour ofString.split()
- replacing the
while
loop with a call toCollections.addAll(T...)
Like so:
while ((currentLine = bufferedReader.readLine()) != null) {
Collections.addAll(arrayList, currentLine.split(" ")));
}
The static method Collections.addAll()
is preferable to arrayList.addAll(Arrays.asList())
:
public static <T> boolean addAll(Collection<? super T> c, T... elements)
Adds all of the specified elements to the specified collection. Elements to be added may be specified individually or as an array. The behavior of this convenience method is identical to that of
c.addAll(Arrays.asList(elements))
, but this method is likely to run significantly faster under most implementations.
This is probably not your bottleneck, but you could achieve the same result by:
- ditching the
StringTokenizer
in favour ofString.split()
- replacing the
while
loop with a call toCollections.addAll(T...)
Like so:
while ((currentLine = bufferedReader.readLine()) != null) {
Collections.addAll(arrayList, currentLine.split(" ")));
}
The static method Collections.addAll()
is preferable to arrayList.addAll(Arrays.asList())
:
public static <T> boolean addAll(Collection<? super T> c, T... elements)
Adds all of the specified elements to the specified collection. Elements to be added may be specified individually or as an array. The behavior of this convenience method is identical to that of
c.addAll(Arrays.asList(elements))
, but this method is likely to run significantly faster under most implementations.
This is probably not your bottleneck, but you could achieve the same result by:
- ditching the
StringTokenizer
in favour ofString.split()
- replacing the
while
loop with a call toCollections.addAll(T...)
Like so:
while ((currentLine = bufferedReader.readLine()) != null) {
Collections.addAll(arrayList, currentLine.split(" ")));
}
The static method Collections.addAll()
is preferable to arrayList.addAll(Arrays.asList())
:
public static <T> boolean addAll(Collection<? super T> c, T... elements)
Adds all of the specified elements to the specified collection. Elements to be added may be specified individually or as an array. The behavior of this convenience method is identical to that of
c.addAll(Arrays.asList(elements))
, but this method is likely to run significantly faster under most implementations.
This is probably not your bottleneck, but you could achieve the same result by:
- ditching the
StringTokenizer
in favour ofString.split()
- replacing the
while
loop with a call toArrayList<T>Collections.addAll(T...)
Like so:
while ((currentLine = bufferedReader.readLine()) != null) {
arrayListCollections.addAll(Arrays.asList(arrayList, currentLine.split(" ")));
}
The static method Collections.addAll()
is preferable to arrayList.addAll(Arrays.asList())
:
public static <T> boolean addAll(Collection<? super T> c, T... elements)
Adds all of the specified elements to the specified collection. Elements to be added may be specified individually or as an array. The behavior of this convenience method is identical to that of
c.addAll(Arrays.asList(elements))
, but this method is likely to run significantly faster under most implementations.
This is probably not your bottleneck, but you could achieve the same result by:
- ditching the
StringTokenizer
in favour ofString.split()
- replacing the
while
loop with a call toArrayList<T>.addAll()
Like so:
while ((currentLine = bufferedReader.readLine()) != null) {
arrayList.addAll(Arrays.asList(currentLine.split(" ")));
}
This is probably not your bottleneck, but you could achieve the same result by:
- ditching the
StringTokenizer
in favour ofString.split()
- replacing the
while
loop with a call toCollections.addAll(T...)
Like so:
while ((currentLine = bufferedReader.readLine()) != null) {
Collections.addAll(arrayList, currentLine.split(" ")));
}
The static method Collections.addAll()
is preferable to arrayList.addAll(Arrays.asList())
:
public static <T> boolean addAll(Collection<? super T> c, T... elements)
Adds all of the specified elements to the specified collection. Elements to be added may be specified individually or as an array. The behavior of this convenience method is identical to that of
c.addAll(Arrays.asList(elements))
, but this method is likely to run significantly faster under most implementations.
This is probably not your bottleneck, but you could achieve the same result by:
- ditching the
StringTokenizer
in favour ofString.split()
- replacing the
while
loop with a call toArrayList<T>.addAll()
Like so:
while ((currentLine = bufferedReader.readLine()) != null) {
arrayList.addAll(Arrays.asList(currentLine.split(" ")));
}