Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
91 lines (86 loc) · 3.17 KB

File metadata and controls

91 lines (86 loc) · 3.17 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import java.io.*;
public class FileToFile {
public static void t1() {
try (FileInputStream fis = new FileInputStream("D:/Downloads/GOKUL.txt");
FileOutputStream fos = new FileOutputStream("D:/Downloads/Dham.txt");) {
byte arr[]=fis.readAllBytes();
String str=new String(arr);
fis.close();
fos.write(str.toLowerCase().getBytes());
fos.close();
} catch (IOException e) {
System.out.println(e);
}
}
public static void t2Mama() {
try (FileInputStream fis = new FileInputStream("D:/Downloads/GOKUL.txt");
FileInputStream fis2 = new FileInputStream("D:/Downloads/Dham.txt");
FileOutputStream fos = new FileOutputStream("D:/Downloads/Society.txt");) {
byte arr[]=fis.readAllBytes();
byte brr[]=fis2.readAllBytes();
fis.close();
fis2.close();
fos.write(arr);
fos.write(brr);
fos.close();
} catch (IOException e) {
System.out.println(e);
}
}
public static void dataStream() throws Exception{
FileOutputStream fos= new FileOutputStream("D:\\Downloads\\sam.txt");
DataOutputStream dos = new DataOutputStream(fos);
double arr[]={12.3, 1223, 34,24546547,1};
dos.writeInt(5);
for(double d:arr){
dos.writeDouble(d);
}
dos.close();
FileInputStream fis= new FileInputStream("D:\\Downloads\\sam.txt");
DataInputStream dis = new DataInputStream(fis);
for(int i=dis.readInt();i>0;i--){
System.out.println(dis.readDouble());
}
dis.close();
}
public static void objectStream()throws Exception {
FileOutputStream fos=new FileOutputStream("D:\\Downloads\\Customer.txt");
ObjectOutputStream obj=new ObjectOutputStream(fos);
Customer sam=new Customer("123","samihan","9309596756");
Customer ved=new Customer("456","Vedant","9022058343");
Customer vrd=new Customer("789","varad","zhoplay");
Customer arr[]={sam,ved,vrd};
obj.writeInt(arr.length);
for(Customer c:arr)
obj.writeObject(c);
obj.close();
fos.close();
System.out.println(Customer.noOfCustomer);
FileInputStream fis=new FileInputStream("D:\\Downloads\\Customer.txt");
ObjectInputStream ois=new ObjectInputStream(fis);
for(int i=ois.readInt();i>0;i--){
System.out.println((Customer)ois.readObject());
}
ois.close();
fis.close();
}//copyright belogs to vedant object
public static void main(String[] args) throws Exception{
objectStream();
}
}
class Customer implements Serializable{
String custId;
String name;
String phoneNo;
static int noOfCustomer=0;
public Customer(){}
public Customer(String custId,String name,String phoneNo){
this.name=name;
this.custId=custId;
this.phoneNo=phoneNo;
noOfCustomer++;
}
public String toString(){
return "customer-Id:"+custId+"\t name:"+name+"\tphone no:"+phoneNo;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.