zoukankan      html  css  js  c++  java
  • RandomeAccessFile

    RandomeAccessFile

    use write replace writeBytes

    public class RandomAccessFileTest {
        public static void main(String[] args) {
            try {
                RandomAccessFile file= new RandomAccessFile("c://temp//in.txt","rw");
                System.out.println(file.readLine());
                
                file.seek(file.length());
                //clear all
    //            file.setLength(0l);
                
                //use write() to replace writeBytes
                file.write("hello ross test".getBytes());
                //writeBytes will has issue on UTF8
    //            file.writeBytes("");
                file.close();
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
  • 相关阅读:
    Day10
    Day9
    Day8
    Day 7
    Day-6
    java中的原子性
    java 原子性
    内存可见性
    JVM 常忘笔记
    JVM 解释执行 编译执行 JIT
  • 原文地址:https://www.cnblogs.com/kakaisgood/p/9542287.html
Copyright © 2011-2022 走看看