「javadat」javadate转yyyymmdd

博主:adminadmin 2022-12-28 05:24:08 59

本篇文章给大家谈谈javadat,以及javadate转yyyymmdd对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

用java怎么分割dat文件

用java怎么分割dat文件

//读取时, 只要 readFile("C:\\test.dat");

public String readFile(String path) throws IOException...{

File file=new File(path);

if(!file.exists()||file.isDirectory())

throw new FileNotFoundException();

BufferedReader br=new BufferedReader(new FileReader(file));

String temp=null;

StringBuffer sb=new StringBuffer();

temp=br.readLine();

while(temp!=null)...{

sb.append(temp+" ");

temp=br.readLine();

}

return sb.toString();

}

java 读取dat文件

可以通过BufferedReader 流的形式进行流缓存,之后通过readLine方法获取到缓存的内容。

BufferedReader bre = null;

try {

String file = "D:/test/test.dat";

bre = new BufferedReader(new FileReader(file));//此时获取到的bre就是整个文件的缓存流

while ((str = bre.readLine())!= null) // 判断最后一行不存在,为空结束循环

{

System.out.println(str);//原样输出读到的内容

};

备注: 流用完之后必须close掉,如上面的就应该是:bre.close(),否则bre流会一直存在,直到程序运行结束。

java代码生成dat文件

File filename = new File("F:\\zd.dat");

说明:dat可以改成任何扩展名,是自己可以定义的,如下:

public void createFile(){

//path表示所创建文件的路径

String path = "d:/tr/rt";

File f = new File(path);

if(!f.exists()){

f.mkdirs();

// fileName表示创建的文件名;为txt类型;

String fileName="test.txt";

File file = new File(f,fileName);

if(!file.exists()){

try {

file.createNewFile();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

//现在可以在d:/tr/rt 目录下找到test.txt文件

如何用java调用dat文件

使用IO流

假设你说的DAT文件在c盘根目录下,名字为1.dat

try

FileReader f=new FileReader("c:\\1.dat");

f.read(ch,1024,1024);

catch (IOException e)

{

system.out.printin(e.toString());

}

finally

{

f.close();

}

java在dat文件中读取数据并进行快速排序

import java.io.DataInputStream;

import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

public class Reader {

public static String[] read(String fileName) throws IOException

{

File file=new File(fileName);

int num;

StringBuffer sb=new StringBuffer();

if(!file.exists())

{

file.createNewFile();

}

DataInputStream din=new DataInputStream(new FileInputStream(file));

byte[] data=new byte[1024];

while((num=din.read(data, 0, 1024))!=-1)

{

sb.append(new String(data,0,num));

}

return sb.toString().split(",");

}

public static void main(String args[])

{

try {

String[] array=read("D://test.dat");

for(String str:array)

{

System.out.println(str);

}

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

JAVA中怎么读取DAT文件中的内容

//调用时, 只要 readFile("C:\\test.dat");

public String readFile(String path) throws IOException...{

         File file=new File(path);

         if(!file.exists()||file.isDirectory())

             throw new FileNotFoundException();

         BufferedReader br=new BufferedReader(new FileReader(file));

         String temp=null;

         StringBuffer sb=new StringBuffer();

         temp=br.readLine();

         while(temp!=null)...{

             sb.append(temp+" ");

             temp=br.readLine();

         }

         return sb.toString();

     }

关于javadat和javadate转yyyymmdd的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

The End

发布于:2022-12-28,除非注明,否则均为首码项目网原创文章,转载请注明出处。