当前位置: 首页>>代码示例>>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;未经允许,请勿转载。