Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java create file if not exists

File yourFile = new File("score.txt");
yourFile.createNewFile(); // if file already exists will do nothing 
FileOutputStream oFile = new FileOutputStream(yourFile, false); 
Comment

java create file if not exists

String yourFile = "YourFile.txt";
String yourContent = "YourContent"

File tmpDir = new File(yourFile);
boolean exists = tmpDir.exists();

if(!exists) {
	FileOutputStream fos = new FileOutputStream(yourFile);
	fos.write(yourContent.getBytes());
	fos.flush();
	fos.close();
}
Comment

PREVIOUS NEXT
Code Example
Java :: get type of variable java 
Java :: java char to charsequence 
Java :: how to generate random number in java 
Java :: java string remove more than one space 
Java :: Uri from bitmap java android 
Java :: iterating over a hashmap 
Java :: optional throw if present 
Java :: area of circle in java 
Java :: how to convert arraylist to array in java 
Java :: loop through string in java 
Java :: how to resize image in android programmatically 
Java :: Spring boot fix cors problem 
Java :: intent in fragment android 
Java :: get username from jwt token request spring boot 
Java :: enum type spring boot entity 
Java :: min priority queue in java 
Java :: check last character of a string java 
Java :: generate 5 digit random string in java 
Java :: slice a list java 
Java :: get time android 
Java :: write input stream to file java 
Java :: java stream get list of one field 
Java :: upload byte array to oss 
Java :: get input in java using joptionpane 
Java :: get driver mysql 
Java :: java jtable change column color 
Java :: calendar.year java 
Java :: How to determine if a binary tree has a certain root to leaf target sum value, in Java? 
Java :: java find all of letter in string 
Java :: How to efficiently find the next greater permutation of a list of values, in Java? 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =