由买买提看人间百态

topics

全部话题 - 话题: numlines
(共0页)
b******y
发帖数: 9224
1
Random rand = new Random();
BufferedReader reader = new BufferedReader(new FileReader("bigfile.txt"));
// get the number of lines
int numLines = 0;
while (true)
{
String line = reader.readLine();
if (line == null) break;
numLines++;
}
// second pass, randomly get a line
String line = null;
float threshHold = 1 / (float) numLines;
for (int i = 0; i < numLines; i++)
{
line = reader.readLine();
if (rand.nextFloat() < threshHold)
{
// we got the line, break
break;... 阅读全帖
h******u
发帖数: 155
2
来自主题: CS版 - 有没有做编译的大牛
parse formated text文本为啥要用这些复杂的 parser generator呀?你说的功能
perl 下面几行就可以搞定了
@lines = `cat filename`;
$numLines = scalar(@lines);
for($p =0; $p < $numLines; $p++){
$line = $fileLines[$i];
if($line =~ /\(w+\)\:\(w+\)/){
$key = $1;
$value = $2;
}
}
$1, $2就是你要的东西 “姓名“ 和 “xxx“
a*******e
发帖数: 3021
3
来自主题: Linux版 - anybody has this issue too? :)
Increasing mouse scroll speed in firefox
http://osnovice.blogspot.com/2007/04/test.html
If you are using firefox in Ubuntu Linux, you might have wondered how you
can
change mouse scroll speed.
To do that, you should roll up your sleeves and go to the hidden firefox
settings. In address bar type:
about:config
You will see a textbox and a long list of options and settings. In the
"filter" textbox type:
mousewheel.withnokey.sysnumlines
Change the default value to "false". Then type:
mousewheel.with... 阅读全帖
(共0页)