


package javalike; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class ExampleArrayFile { public ExampleArrayFile() { } public static int[] read() { String filename = "array.txt"; String strArray = ""; String line; try { BufferedReader in = new BufferedReader(new FileReader(filename)); while ((line = in.readLine()) != null) { strArray += line + " "; } in.close(); } catch (IOException e) { e.printStackTrace(); } String[] temp = strArray.split(" "); int array[] = new int[temp.length]; for (int i = 0; i < array.length; i++) { array[i] = Integer.parseInt(temp[i]); } return array; } public static void write(int[] x) { String filename = "array.txt"; BufferedWriter outputWriter = null; try { outputWriter = new BufferedWriter(new FileWriter(filename)); for (int i = 0; i < x.length; i++) { outputWriter.write(x[i] + ""); outputWriter.newLine(); } outputWriter.flush(); outputWriter.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void main(String[] args) { int a[] = { 1, 5, 10, 123, 44, 88, 99, 147 }; // write an array to a file write(a); // Reading array in file int b[] = read(); System.out.println(b[5]); b[5] += 10; b[2] = 6; b[7] = 1000; // write an array to a file write(b); } } |
.png)
| int a[] = { 1, 5, 10, 123, 44, 88, 99, 147 }; // write an array to a file write(a); // Reading array in file int b[] = read(); System.out.println(b[5]); b[5] += 10; b[2] = 6; b[7] = 1000; // write an array to a file write(b); |
| 88 |
.png)

بستن *نام و نام خانوادگی * پست الکترونیک * متن پیام |
دوره های آموزشی برنامه نویسی
انجام پروژه های برنامه نویسی
تدریس خصوصی برنامه نویسی
بیش از 7 سال از فعالیت جاواپرو میگذرد
جاواپرو دارای مجوز نشر دیجیتال از وزارت فرهنگ و ارشاد اسلامی است
جهت ارتباط مستقیم با جاواپرو در واتساپ و تلگرام :
09301904690




![مشاهده سرفصل ها و ثبت نام در دوره Spring Boot جاواپرو [کلیک کنید]](https://dl.javapro.ir/image/marketing/banerday1403springboot.png)
























.png)
-min.png)
-min.png)
-min.png)


-min.png)









-min.png)

.jpg)
