Skip to content

Instantly share code, notes, and snippets.

@akexorcist
Last active August 4, 2024 17:03
Show Gist options
  • Save akexorcist/10010827 to your computer and use it in GitHub Desktop.
Save akexorcist/10010827 to your computer and use it in GitHub Desktop.
ฟังก์ชันเขียนไฟล์ txt ธรรมดาๆ โดยมีแบบเขียนทับหรือเขียนต่อจากเดิม
public void appendTextFile(String text) {
File file = new File("sdcard/text.txt");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
BufferedWriter buf = new BufferedWriter(new FileWriter(file, true));
buf.append(text);
buf.newLine();
buf.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public void createTextFile(String text) {
File file = new File("sdcard/text.txt");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
BufferedWriter buf = new BufferedWriter(new FileWriter(file, false));
buf.append(text);
buf.newLine();
buf.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Surachet6338
Copy link

123

@Flook7533
Copy link

Flook7533 commented Aug 4, 2024

pip install requests

@Flook7533
Copy link

pip install requests

@Flook7533
Copy link

pip install requests

@Flook7533
Copy link

Flook7533 commented Aug 4, 2024

> pip install requests

``

@Flook7533
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment