// init the file objects and the initial drive state
public class UsbDetector
for ( int i = 0; i < letters.length; ++i )
{
usb[i] = new File(letters[i]+":/");
isDrive[i] = usb[i].canRead();
}
System.out.println("waiting for USB...");
// loop indefinitely
while(true)
{
// check each drive
for ( int i = 0; i < letters.length; ++i )
{
boolean pluggedIn = usb[i].canRead();
// if the state has changed output a message
if ( pluggedIn != isDrive[i] )
{
if ( pluggedIn )
System.out.println("Drive "+letters[i]+" has been inserted");
else
System.out.println("Drive "+letters[i]+" has been removed");
isDrive[i] = pluggedIn;
};
答案 0 :(得分:0)
如何在Label Javafx中显示println
Label label = new Label(yourText);
或
label.setText(yourText);