هذا الكود للقراءة من ملف text وطباعته
وطباعه عدد الحروف(bytes)
هذا الكود للقراءة من ملف text وطباعته
وطباعه عدد الحروف(bytes)
import java.io.*;
public class ReadFile
{
public static void main(String[] args) throws IOException
{
FileInputStream in=new FileInputStream("Memo.txt");
// the Memo text file must be found in the main directory that contain class,src
byte buf[]=new byte[128];
int bytecnt=0;
String line;
in.read(buf,0,128);//read from text and put in buf
String s=new String(buf,0);
System.out.println(s);
//in.close();
in=new FileInputStream("Memo.txt");//open connection again to count it
while(in.read() != -1)
{
bytecnt++;
}
System.out.println("The count of text is " + bytecnt + " in bytes");
}
}شكرا اخي نحن بحاجة الى مثل هذه الاكواد البسيطة و المفيدة و بشكل كبير لكي ننقلها الى الآرشيف فهو شبه فارغ
Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why
السلام عليكم
اين هذا الآرشيف اخي لا اعلم اين هو ارجوا ان تخبرني مكانه للتعامل مع مباشرة (f)
لمعرفة حجم ملف معين يمكن استخدام
import java.io.*;
public class MyReadFile
{
public static void main(String[] args) throws IOException
{
File F=new File("C:Dokumente und EinstellungenkhaledDesktopdata.txt");
System.out.println(F.length());
}
}جزاك الله خيرا
هذا الموضوع مغلق.