我有一个Java RandomAccessFile
。我经常检查文件的长度。该文件来自scp
。因此,文件将被追加。
我想知道RandomAccessFile
的更新频率。每当我检查RandomAccessFile.length
时,都会得到准确的length
?
答案 0 :(得分:2)
由于该方法是原生的,我建议您查看OpenJDK源代码。它是您与实际实施最接近的事情(除非您为Oracle工作; - )。
可以在此处找到源代码(它在所有操作系统之间共享):src/share/native/java/io/RandomAccessFile.c
<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="adventureStylez.css">
<script type="text/javascript" src="jquery-1.12.0.js">
var adventureGame = [
{
"src": "http://people.emich.edu/egurnee/assets/dixit/books.jpg",
"desc": "You find yourself overwhelmed with homework. You must relieve yourself of stress before you can even begin to accomplish anything. What do you do?",
"loc": 0,
"type": "choice",
"choices": [
{
"desc": "Attempt some math homework.",
"loc": 1
},
{
"desc": "Go for a calming night walk on the dock by the ocean.",
"loc": 2
}
]
},
{
"src": "http://people.emich.edu/egurnee/assets/dixit/math.jpg",
"desc": "The attempt to complete math homework resulted in more stress. Now what do you do?",
"loc": 1,
"type": "choice",
"choices": [
{
"desc": "Go for a calming night walk on the dock by the ocean.",
"loc": 2
},
{
"desc": "Paint a picture.",
"loc": 3
}
]
},
{
"src": "http://people.emich.edu/egurnee/assets/dixit/dock.jpg",
"desc": "The dock is very unstable. You must hold your balance, but you are having trouble with it. What do you do?",
"loc": 2,
"type": "choice",
"choices": [
{
"desc": "Go back home and paint a picture.",
"loc": 3
},
{
"desc": "Use your inner zen energy to persevere and finish the walk on the dock.",
"loc": 4
}
]
},
{
"src": "http://people.emich.edu/egurnee/assets/dixit/tree.jpg",
"desc": "You paint a beautiful of a girl and a tree. Now you feel bored. What do you do?",
"loc": 3,
"type": "choice",
"choices": [
{
"desc": "Use your inner zen energy to conquer that dock.",
"loc": 4
},
{
"desc": "Go beat that metal octopus' ass that has been harassing your dog at night.",
"loc": 5
}
]
},
{
"src": "http://people.emich.edu/egurnee/assets/dixit/balance.jpg",
"desc": "You made that dock your bitch. All of a sudden you feel an intense amount of adrenaline. What do you do?",
"loc": 4,
"type": "choice",
"choices": [
{
"desc": "Jump in the ocean.",
"loc": 6
},
{
"desc": "Go beat that metal octopus' ass that has been harassing your dog at night.",
"loc": 5
}
]
},
{
"src": "http://people.emich.edu/egurnee/assets/dixit/metaloctopus.jpg",
"desc": "That octopus is done for. Congratulations you have won!",
"loc": 5,
"type": "choice",
"choices": [
{
"desc": "Play again?",
"loc": 0
}
]
},
{
"src": "http://people.emich.edu/egurnee/assets/dixit/sad-bear.jpg",
"desc": "Oh, no! When you jumped in the ocean you were eaten by a shark. Try again.",
"loc": 6,
"type": "choice",
"choices": [
{
"desc": "Try again?",
"loc": 0
}
]
}
];
function add_choice(desc, loc) {
$("#response").append("<button class=choice data-loc=" + loc + ">" + desc + "</button>");
}
function set_page_desc(desc) {
$("#page_desc").append("<p>" + desc + "</p>");
}
function set_page_img(src){
$("#page_img").append("<img src =\" " + src + "\">")
}
function clear_page() {
$("#page_desc").empty();
$("#response").empty();
}
function load_page(id) {
// Fetch JSON for page data associated with given ID
var page_data = adventureGame[id];
clear_page();
set_page_img(page_data.src);
set_page_desc(page_data.desc);
if (page_data.type === 'choice') {
for (var choice in page_data.choices) {
var choice_data = page_data.choices[choice];
add_choice(choice_data.desc, choice_data.loc);
}
}
}
var current_page = 0;
$(document).ready(function () {
load_page(0);
$('#response').on('click', '.choice', function () {
var loc = $(this).data('loc');
load_page(loc);
});
});
</script>
<title>My Choose Your Own Adventure Game</title>
</head>
<body>
<script type="text/javascript" src="jquery-1.12.0.js">
$(document).ready(function () {
load_page(0);
$('#response').on('click', '.choice', function () {
var loc = $(this).data('loc');
load_page(loc);
});
});
</script>
<div id="page" class="blockCenter">
<div id="page_img"></div>
<div id="page_desc"></div>
<div id="response"></div>
</div>
</body>
</html>
是的,它会尝试找到tl;dr
所指的文件描述符的结尾。