-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasic_FILE_HADLING.java
More file actions
28 lines (20 loc) · 883 Bytes
/
Copy pathBasic_FILE_HADLING.java
File metadata and controls
28 lines (20 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.io.*;
public class Basic_FILE_HADLING {
public static void main(String args[]) throws IOException {
File fileName = new File("C:\\Users\\hp\\Downloads\\[CSE3141] Attendance - Sheet1 (1).csv");
FileInputStream inFile = new FileInputStream("C:\\Users\\hp\\Downloads\\[CSE3141] Attendance - Sheet1 (1).csv");
int fileLength = (int) fileName.length();
byte Bytes[] = new byte[fileLength];
System.out.println("File size is: " + inFile.read(Bytes));
String file1 = new String(Bytes);
System.out.println("File content is:\n" + file1);
FileOutputStream outFile = new FileOutputStream("C:\\Users\\hp\\Desktop\\Untitled.txt");
for (int i = 0; i < fileLength; i++) {
outFile.write(Bytes[i]);
}
System.out.println("File copied.");
// close files
inFile.close();
outFile.close();
}
}