當前位置: 首頁>>代碼示例>>Java>>正文


Java FileWriter.close方法代碼示例

本文整理匯總了Java中java.io.FileWriter.close方法的典型用法代碼示例。如果您正苦於以下問題:Java FileWriter.close方法的具體用法?Java FileWriter.close怎麽用?Java FileWriter.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.FileWriter的用法示例。


在下文中一共展示了FileWriter.close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: btnSaveAsActionPerformed

import java.io.FileWriter; //導入方法依賴的package包/類
private void btnSaveAsActionPerformed(ActionEvent paramActionEvent) {
    JFileChooser localJFileChooser = new JFileChooser();
    localJFileChooser.addChoosableFileFilter(new JavaFileFilter("html", "HTML Files"));
    localJFileChooser.addChoosableFileFilter(new JavaFileFilter("doc", "Document Files"));
    localJFileChooser.addChoosableFileFilter(new JavaFileFilter("txt", "Text Files"));
    int i = localJFileChooser.showSaveDialog(this);
    if (i != 0) {
        return;
    }
    String str = localJFileChooser.getSelectedFile().getAbsolutePath();
    try {
        FileWriter localFileWriter = new FileWriter(str, false);
        localFileWriter.write(this.txtSumary.getText());
        localFileWriter.close();
    } catch (FileNotFoundException localFileNotFoundException) {
        localFileNotFoundException.printStackTrace();
        return;
    } catch (IOException localIOException) {
        localIOException.printStackTrace();
        return;
    }
}
 
開發者ID:dmitrykolesnikovich,項目名稱:featurea,代碼行數:23,代碼來源:SummaryDialog.java

示例2: writeReadTest

import java.io.FileWriter; //導入方法依賴的package包/類
@Test
public void writeReadTest() throws Exception {
  LocalEncryptionKeyContainer container = new LocalEncryptionKeyContainer();
  container.addKey("a", "b", 1, new byte[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1});
  container.addKey("a", "b", 2, new byte[] {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2});
  container.addKey("d", 3, new byte[] {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3});
  container.addKey("d", 4, new byte[] {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4});

  File file = folder.newFile();
  FileWriter writer = new FileWriter(file);
  container.write(writer);
  writer.flush();
  writer.close();

  LocalEncryptionKeyContainer container2 = LocalEncryptionKeyContainer.read(new FileReader(file));
  assertThat("has matching keys", container2.getAttributeKey("a", "b", 1, 16), equalTo(container.getAttributeKey("a", "b", 1, 16)));
  assertThat("has matching keys", container2.getAttributeKey("a", "b", 2, 16), equalTo(container.getAttributeKey("a", "b", 2, 16)));
  assertThat("has matching keys", container2.getKey("d", 3, 16), equalTo(container.getKey("d", 3, 16)));
  assertThat("has matching keys", container2.getKey("d", 4, 16), equalTo(container.getKey("d", 4, 16)));
}
 
開發者ID:mit-ll,項目名稱:PACE,代碼行數:21,代碼來源:LocalEncryptionKeyContainerTest.java

示例3: main

import java.io.FileWriter; //導入方法依賴的package包/類
public static void main(String[] args) {

    int size = 100;
    creatStr(size, size);
    createFile(size);
    createDir(size);
    createRoot();
    createContents(size, size);

    str += "\n\ncontents in Dir -> (Dir + File)\n" + "all d:Dir | not (d in d.^contents)\n"
        + "Root in Dir\n" + "(File + Dir) in Root.*contents";
    System.out.println(str);

    File tempFile = new File(
        "./../eu.modelwriter.traceability.validation.core.crocopat/files/KodKodTestFile.kodkod");

    try {
      FileWriter fileWriter = new FileWriter(tempFile);
      fileWriter.write(str);
      fileWriter.flush();
      fileWriter.close();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:27,代碼來源:UniverseCreateForKodKod.java

示例4: process

import java.io.FileWriter; //導入方法依賴的package包/類
public void process(File pdf, File output){
        PDDocument pdDoc;
        try {//Kudos for closing: http://stackoverflow.com/questions/156508/closing-a-java-fileinputstream
            File tmpfile = File.createTempFile(String.format("txttmp-%s", UUID.randomUUID().toString()), null);
            RandomAccessFile raf = new RandomAccessFile(tmpfile, "rw");
            pdDoc = PDDocument.loadNonSeq(pdf, raf);
            FileWriter writer = new FileWriter(output);
            try {
                PDFTextStripper stripper = new PDFTextStripper();
                int numberOfPages = pdDoc.getNumberOfPages();

                for (int j = 1; j < numberOfPages+1; j++) {
                    stripper.setStartPage(j);
                    stripper.setEndPage(j);
                    writer.write(stripper.getText(pdDoc));
                    writer.flush();
                }
            } finally {
                pdDoc.close();
                raf.close();
                tmpfile.delete();
                writer.close();
            }
        } catch (IOException ioe) {
//            log.warn(String.format("Failed to create txt for file: %s", pdf.getName()), ioe);
        }
    }
 
開發者ID:jmrozanec,項目名稱:pdf-converter,代碼行數:28,代碼來源:TxtCreator.java

示例5: log

import java.io.FileWriter; //導入方法依賴的package包/類
@Override
public void log(String datos) {
	File file = new File("log.txt");
	try {
		FileWriter fW = new FileWriter(file, true);
		fW.write(new Date() + " - " + datos + "\n");
		fW.close();

	} catch (IOException e) {
		e.printStackTrace();
	}

}
 
開發者ID:Arquisoft,項目名稱:dashboard1b,代碼行數:14,代碼來源:WReportR.java

示例6: writeFileLines

import java.io.FileWriter; //導入方法依賴的package包/類
static void writeFileLines(Vector v, File f) throws IOException {

        FileWriter write = new FileWriter(f);

        for (int i = 0; i < v.size(); i++) {
            write.write((String) v.elementAt(i));
            write.write(ls);
        }

        write.flush();
        write.close();
    }
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:13,代碼來源:CodeSwitcher.java

示例7: write

import java.io.FileWriter; //導入方法依賴的package包/類
public static void write(String path, String data) {
    if (!TextUtils.isEmpty(path)) {
        try {
            FileWriter writer = new FileWriter(path);
            writer.write(data);
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:auv1107,項目名稱:TextEmoji,代碼行數:12,代碼來源:FileAccessUtils.java

示例8: saveToFile

import java.io.FileWriter; //導入方法依賴的package包/類
public void saveToFile(Object data, File location){
	XStream xstream = new XStream(new DomDriver());
	String content = xstream.toXML(data);
	try {
		FileWriter fileWriter = new FileWriter(location);
		fileWriter.write(content);
		fileWriter.close();
	} catch (Exception e) {
		// user clicked cancel. No need to exclaim anything went wrong
	}
}
 
開發者ID:LtubSalad,項目名稱:voogasalad-ltub,代碼行數:12,代碼來源:XStreamHandler.java

示例9: appendDataToTempFile

import java.io.FileWriter; //導入方法依賴的package包/類
/**
 * Appends the given data to the file specified in the input and returns the
 * reference to the file.
 * 
 * @param file
 * @param dataToAppend
 * @return reference to the file.
 * @throws IOException
 */
public static File appendDataToTempFile(File file, String dataToAppend)
        throws IOException {
    FileWriter outputWriter = new FileWriter(file);

    try {
        outputWriter.append(dataToAppend);
    } finally {
        outputWriter.close();
    }

    return file;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:22,代碼來源:FileUtils.java

示例10: main

import java.io.FileWriter; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public static void main(String[] args) throws Exception {
    Class[] voClassesInPackage = getClasses(VO_VERSION_PACKAGE);
    VOConverterTestGenerator generator = new VOConverterTestGenerator(
            voClassesInPackage);
    FileWriter fw = null;
    try {
        fw = generator.createOutputFile();
        generator.writeCode(fw);
    } finally {
        if (fw != null) {
            fw.close();
        }
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:16,代碼來源:VOConverterTestGenerator.java

示例11: writerToFile

import java.io.FileWriter; //導入方法依賴的package包/類
private static void writerToFile(File file, String contents) throws Throwable {

		if (!file.getParentFile().exists()) {
			file.getParentFile().mkdirs();
		}

		FileWriter filewriter = new FileWriter(file);
		filewriter.write(contents);
		filewriter.flush();
		filewriter.close();
	}
 
開發者ID:sparkworks-co-jp,項目名稱:sourcehelper,代碼行數:12,代碼來源:Writer.java

示例12: writeFile

import java.io.FileWriter; //導入方法依賴的package包/類
private static void writeFile(String output, File file, boolean append) {
	try {
		FileWriter writer = new FileWriter(file, append);
		writer.write(output);
		writer.close();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:BenjaminAlbrecht84,項目名稱:DAA_Converter,代碼行數:10,代碼來源:MAF_Streamer.java

示例13: export

import java.io.FileWriter; //導入方法依賴的package包/類
/**
 * The export method is used to carry out the writing to the CSV File. This
 * method calls other helper methods which perform the writing operations.
 *
 * @param csvFilePath path to which the file will be exported.
 * @throws IOException
 */
public void export(final String csvFilePath) throws IOException {

	final FileWriter writer = new FileWriter(csvFilePath);
	try {
		// Total Number of Components
		writeHeader(writer, "Component Summary");
		totalCounts(writer);

		CSVUtils.writeLine(writer, Arrays.asList("")); // empty line

		// Total Number of sub-types of the Components such as Comm Points, Routes, Filters and Definitions.
		writeHeader(writer, "Total Number of types of Components");
		totalCommPointTypes(writer);
		// general properties of each comm point:
		generalProperties(writer);
		totalFilterTypes(writer);
		totalFilterCountsPerRoute(writer);
		totalDefinitionsCountsPerRoute(writer);
		totalDefinitionTypes(writer);
		// Add the Rhapsody Version numbers
		rhapsodyVersionNumbers(writer);

		writer.flush();
	} finally {
		writer.close();
	}
}
 
開發者ID:orionhealth,項目名稱:rlc-analyser,代碼行數:35,代碼來源:RLCDataExporter.java

示例14: writeFile

import java.io.FileWriter; //導入方法依賴的package包/類
static File writeFile(File base, String path, String body) throws IOException {
    File f = new File(base, path);
    FileWriter out = new FileWriter(f);
    out.write(body);
    out.close();
    System.err.println("wrote " + path + ": " + body);
    return f;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:T7068451.java

示例15: saveSchema

import java.io.FileWriter; //導入方法依賴的package包/類
@BeforeClass
public static void saveSchema() throws IOException {
  oldTestBuildDataProp = System.getProperty(TEST_BUILD_DATA_KEY);
  System.setProperty(TEST_BUILD_DATA_KEY, DFS_DIR);
  FileWriter schema = new FileWriter(SCHEMA_FILE);
  schema.append(RECORD_SCHEMA.toString());
  schema.close();
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:9,代碼來源:TestDatasetSink.java


注:本文中的java.io.FileWriter.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。