当前位置: 首页>>代码示例>>Java>>正文


Java RandomAccessFile.writeChars方法代码示例

本文整理汇总了Java中java.io.RandomAccessFile.writeChars方法的典型用法代码示例。如果您正苦于以下问题:Java RandomAccessFile.writeChars方法的具体用法?Java RandomAccessFile.writeChars怎么用?Java RandomAccessFile.writeChars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.RandomAccessFile的用法示例。


在下文中一共展示了RandomAccessFile.writeChars方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createRandomFile

import java.io.RandomAccessFile; //导入方法依赖的package包/类
private static File createRandomFile(String uuid, Long size) throws IOException {
  File file  = new File("/tmp/" + uuid + ".txt");
  RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
  randomAccessFile.writeChars(uuid);
  if (size != null) {
    randomAccessFile.setLength(size);
  }
  randomAccessFile.close();
  return file;
}
 
开发者ID:filestack,项目名称:filestack-java,代码行数:11,代码来源:TestBasicFunctions.java

示例2: createRandomFile

import java.io.RandomAccessFile; //导入方法依赖的package包/类
private static Path createRandomFile(long size) throws IOException {
  Path path = Paths.get("/tmp/" + UUID.randomUUID().toString() + ".txt");
  RandomAccessFile file = new RandomAccessFile(path.toString(), "rw");
  file.writeChars("test content\n");
  file.setLength(size);
  file.close();
  return path;
}
 
开发者ID:filestack,项目名称:filestack-java,代码行数:9,代码来源:TestClient.java

示例3: writeMsgToFile

import java.io.RandomAccessFile; //导入方法依赖的package包/类
private void writeMsgToFile(File targetFile, String msg) {
    FileNotFoundException e;
    Throwable th;
    IOException e2;
    try {
        if (!targetFile.exists()) {
            targetFile.createNewFile();
        }
        if (targetFile != null && targetFile.exists() && !TextUtils.isEmpty(msg)) {
            RandomAccessFile raf = null;
            try {
                RandomAccessFile raf2 = new RandomAccessFile(targetFile, "rw");
                try {
                    raf2.seek(targetFile.length());
                    raf2.writeChars("\n<----" + new Date().toString() + "---->\n");
                    raf2.writeChars(msg);
                    if (raf2 != null) {
                        try {
                            raf2.close();
                        } catch (IOException e3) {
                            raf = raf2;
                            return;
                        }
                    }
                    raf = raf2;
                } catch (FileNotFoundException e4) {
                    e = e4;
                    raf = raf2;
                    try {
                        e.printStackTrace();
                        if (raf != null) {
                            try {
                                raf.close();
                            } catch (IOException e5) {
                            }
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        if (raf != null) {
                            try {
                                raf.close();
                            } catch (IOException e6) {
                            }
                        }
                        throw th;
                    }
                } catch (IOException e7) {
                    e2 = e7;
                    raf = raf2;
                    e2.printStackTrace();
                    if (raf != null) {
                        try {
                            raf.close();
                        } catch (IOException e8) {
                        }
                    }
                } catch (Throwable th3) {
                    th = th3;
                    raf = raf2;
                    if (raf != null) {
                        raf.close();
                    }
                    throw th;
                }
            } catch (FileNotFoundException e9) {
                e = e9;
                e.printStackTrace();
                if (raf != null) {
                    raf.close();
                }
            } catch (IOException e10) {
                e2 = e10;
                e2.printStackTrace();
                if (raf != null) {
                    raf.close();
                }
            }
        }
    } catch (IOException e11) {
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:82,代码来源:CrashHandler.java


注:本文中的java.io.RandomAccessFile.writeChars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。