我想编写一个带有 UI Button Read/Write 的 Android 应用程序,它执行sysfs read
或sysfs write
.
我找到了以下 java.io.RandomAccessFile 的示例代码。
package com.tutorialspoint;
import java.io.*;
public class RandomAccessFileDemo {
public static void main(String[] args) {
try {
// create a new RandomAccessFile with filename test
RandomAccessFile raf = new RandomAccessFile("c:/test.txt", "rw");
// write something in the file
raf.writeUTF("Hello World");
// set the file pointer at 0 position
raf.seek(0);
// read the first byte and print it
System.out.println("" + raf.read());
// set the file pointer at 4rth position
raf.seek(4);
// read the first byte and print it
System.out.println("" + raf.read());
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
有人可以告诉我如何使用 Android sdk 构建此代码吗?