Professional Documents
Culture Documents
BT TH Buoi 3.1
BT TH Buoi 3.1
import javax.swing.JOptionPane;
ketqua *= 100;
if(ketqua >=50){
}else {
import javax.swing.JOptionPane;
public class Ex2WithWhile {
while (youLost) {
if(ketquaInt == inputNumber){
break;
}//end of for
if(!youLost){
}else {
}//end of while
}
Bài 3: Làm việc với f il e văn b ản (txt): Ghi nội du n g ra f il e văn bản.
DataOutputStream dos;
public boolean writeToFile(String fileName, String dataLine,
boolean isAppendMode, boolean isNewLine) {
if (isNewLine) {
dataLine = "\n" + dataLine;
}
try {
File outFile = new File(fileName);
if (isAppendMode) {
dos = new DataOutputStream(new
FileOutputStream(fileName, true));
} else {
dos = new DataOutputStream(new
FileOutputStream(outFile));
}
dos.writeBytes(dataLine);
dos.close();
} catch (FileNotFoundException ex) {
return (false);
} catch (IOException ex) {
return (false);
}
return (true);
4
new
FileInputStream(inFile))); DataLine =
br.readLine();
br.close();
} catch (FileNotFoundException ex) {
return (null);
} catch (IOException
ex) {
return (null);
}
return (DataLine);
}