当前位置: 首页>>代码示例>>Java>>正文


Java FileWriter.write方法代码示例

本文整理汇总了Java中java.io.FileWriter.write方法的典型用法代码示例。如果您正苦于以下问题:Java FileWriter.write方法的具体用法?Java FileWriter.write怎么用?Java FileWriter.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.FileWriter的用法示例。


在下文中一共展示了FileWriter.write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.io.FileWriter; //导入方法依赖的package包/类
public static void main (String[] args) throws IOException {
Simulation sim = new Simulation(Space3D.getInstance());
Box box = new Box(sim.getSpace());

PotentialCalculationMappedRdf pc = new PotentialCalculationMappedRdf(sim.getSpace(),box, 1000000, null);
P2LennardJones potential = new P2LennardJones(sim.getSpace());
P2SoftSphericalTruncated p2Truncated = new P2SoftSphericalTruncated(sim.getSpace(), potential, 4);

pc.setVolume(99999.99999999997);
pc.setTemperature(2, p2Truncated);
double rc = p2Truncated.getRange();
double x0 = rc;

FileWriter fw = new FileWriter("vu.dat");
for (int i=10; i<45; i++) {
    double r = i*0.1;
    if (r>=4) r = 3.99999999;
               System.out.println(r+" "+pc.calcXu(r, p2Truncated.u(r*r))+" ");
               fw.write(r+" "+pc.calcXu(r, p2Truncated.u(r*r))+"\n");
           }

fw.close();

  }
 
开发者ID:etomica,项目名称:etomica,代码行数:25,代码来源:PotentialCalculationMappedRdf.java

示例2: writePackFile

import java.io.FileWriter; //导入方法依赖的package包/类
private void writePackFile(File outputDir, Array<Page> pages, String packFileName) throws IOException {
    File packFile = new File(outputDir, packFileName);
    FileWriter writer = new FileWriter(packFile);
    for (Page page : pages) {
        writer.write("\n"); // todo avoid this
        writer.write(page.imageName + "\n");
        writer.write("size: " + page.canvasWidth + "," + page.canvasHeight + "\n");
        writer.write("format: RGBA8888\n");
        writer.write("filter: Nearest,Nearest\n");
        writer.write("repeat: none\n");
        for (Rect rect : page.outputRects) {
            writeRect(writer, page, rect);
            for (Alias alias : rect.aliases) {
                Rect aliasRect = new Rect();
                aliasRect.set(rect);
                alias.apply(aliasRect);
                writeRect(writer, page, aliasRect);
            }
        }
    }
    writer.close();
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:23,代码来源:TexturePackerManager.java

示例3: main

import java.io.FileWriter; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
	String fileName = "data.txt";
	DataReader in = new DataReader(new FileReader(fileName));
	FileWriter fw = new FileWriter("data-output.txt");

	ArrayList<Data> dataList = new ArrayList<>();
	Data data = new Data();
	
	data.printFields();

	while ((data = in.readData()) != null) {
		dataList.add(data);
		fw.write(data.toString() + System.lineSeparator());
		data.print();
	}
	
	in.close();
	fw.close();
}
 
开发者ID:BedrockDev,项目名称:Sunrin2017,代码行数:20,代码来源:Exam2.java

示例4: initWebXml

import java.io.FileWriter; //导入方法依赖的package包/类
protected void initWebXml() {
    try {
        if (webxmlLevel >= INC_WEBXML) {
            File fmapings = new File(webxmlFile);
            mapout = new FileWriter(fmapings);
            servletout = new CharArrayWriter();
            mappingout = new CharArrayWriter();
        } else {
            mapout = null;
            servletout = null;
            mappingout = null;
        }
        if (webxmlLevel >= ALL_WEBXML) {
            mapout.write(Localizer.getMessage("jspc.webxml.header"));
            mapout.flush();
        } else if ((webxmlLevel>= INC_WEBXML) && !addWebXmlMappings) {
            mapout.write(Localizer.getMessage("jspc.webinc.header"));
            mapout.flush();
        }
    } catch (IOException ioe) {
        mapout = null;
        servletout = null;
        mappingout = null;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:JspC.java

示例5: log

import java.io.FileWriter; //导入方法依赖的package包/类
@Override
public void log(String datos) {		
	File file = new File("logP.txt");

	try {				

		FileWriter fW = new FileWriter(file, true);
		fW.write(new Date()+" - "+datos+"\n");
		fW.close();

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

}
 
开发者ID:Arquisoft,项目名称:dashboard1b,代码行数:16,代码来源:WreportP.java

示例6: cacheSkin

import java.io.FileWriter; //导入方法依赖的package包/类
private void cacheSkin(SkinData skindata){
    JsonObject jsonFile = getChacheFile(plugin);
    JsonArray newskindata = new JsonArray();
    if(jsonFile!=null){
        JsonArray oldskindata = jsonFile.getAsJsonArray("skindata");
        Iterator it = oldskindata.iterator();
        while(it.hasNext()){
            JsonElement element = (JsonElement) it.next();
            if(element.getAsJsonObject().get("id").getAsInt()==this.npcid){
                // element.getAsJsonObject().remove("value");
                //element.getAsJsonObject().remove("signature");
                //element.getAsJsonObject().addProperty("value", skindata.getValue());
                //element.getAsJsonObject().addProperty("signature", skindata.getSignature());
            }else {
                newskindata.add(element);
            }
        }
    }
    JsonObject skin = new JsonObject();
    skin.addProperty("id", this.npcid);
    skin.addProperty("value", skindata.getValue());
    skin.addProperty("signature", skindata.getSignature());
    newskindata.add(skin);

    JsonObject obj = new JsonObject();
    obj.add("skindata", newskindata);
    try {
        plugin.getDataFolder().mkdir();
        File file = new File(plugin.getDataFolder().getPath()+"/truenonpcdata.json");
        file.createNewFile();
        FileWriter writer = new FileWriter(file);
        writer.write(obj.toString());
        writer.close();

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:eltrueno,项目名称:TruenoNPC,代码行数:39,代码来源:TruenoNPC_v1_11_r1.java

示例7: test_executeBuildRetunsZeroResult

import java.io.FileWriter; //导入方法依赖的package包/类
public void test_executeBuildRetunsZeroResult() throws Exception {
  if (!agent.isWindows()) return;
  final FileWriter fw = new FileWriter(script);
  fw.write("rem Test script file \n");
  fw.write("echo test successful\n");
  IoUtils.closeHard(fw);
  assertEquals(0, scriptRunner.executeBuildScript(script.getAbsolutePath()));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:9,代码来源:SSTestWindowsBuildScriptRunner.java

示例8: TestLogResource

import java.io.FileWriter; //导入方法依赖的package包/类
/**
 * 引数に存在する圧縮ファイルパスを渡した場合_レスポンスボディにStreamingOutputオブジェクトが入ったSC_OKレスポンスが返る.
 * ※ レスポンスに返されるログの内容は、本Unitテストでは検査不可なため、別途検証する。
 */
@Test
public void コレクション名がarchiveで引数に圧縮されていないファイルパスを渡した場合_500エラーが返却されること() {
    TestLogResource logResource = new TestLogResource();

    try {
        Method method = LogResource.class.getDeclaredMethod("getLog", new Class[] {String.class, String.class });
        method.setAccessible(true);

        File file = File.createTempFile("TestFile", ".log.zip");
        file.deleteOnExit();

        final String logContent = "a,b,c\n" + "x,y,z\n";
        FileWriter writer = new FileWriter(file);
        try {
            writer.write(logContent);
        } finally {
            writer.close();
        }

        String filename = file.getAbsolutePath();
        String paramFileName = filename.substring(0, filename.length() - ".zip".length());

        // ログ取得実行
        method.invoke(logResource, new Object[] {"archive", paramFileName });
        fail();
    } catch (Exception e) {
        Throwable t = e.getCause();
        assertEquals(PersoniumCoreException.Event.ARCHIVE_FILE_CANNOT_OPEN.getMessage(), t.getMessage());
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:35,代码来源:LogTest.java

示例9: saveToFile

import java.io.FileWriter; //导入方法依赖的package包/类
/**
 * Saves this CrashReport to the given file and returns a value indicating whether we were successful at doing so.
 */
public boolean saveToFile(File toFile)
{
    if (this.crashReportFile != null)
    {
        return false;
    }
    else
    {
        if (toFile.getParentFile() != null)
        {
            toFile.getParentFile().mkdirs();
        }

        try
        {
            FileWriter filewriter = new FileWriter(toFile);
            filewriter.write(this.getCompleteReport());
            filewriter.close();
            this.crashReportFile = toFile;
            return true;
        }
        catch (Throwable throwable)
        {
            logger.error("Could not save crash report to " + toFile, throwable);
            return false;
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:32,代码来源:CrashReport.java

示例10: btnSaveAction

import java.io.FileWriter; //导入方法依赖的package包/类
@FXML
private void btnSaveAction()
{
	FileChooser fileChooser = new FileChooser();
	File file = fileChooser.showSaveDialog(btnSave.getScene().getWindow());
	
	if(file == null)
		return;
	
	try
	{
		FileWriter stream = new FileWriter(file);
		
		try
		{
			file.createNewFile();
			stream.write(txtArea.getText());
		}
		finally
		{
			stream.close();
		}
	}
	catch (IOException e)
	{
		e.printStackTrace();
	}
}
 
开发者ID:tengai650,项目名称:SnapDup,代码行数:29,代码来源:GenerateScriptDialog.java

示例11: parseFile

import java.io.FileWriter; //导入方法依赖的package包/类
public void parseFile(File inputFile, File outputFile) throws ClassificationException, IOException {
	logger.debug("Treating file: '" + inputFile + "'");
	
	
	Map<String, Collection<ClassificationScore>> classificationScores = classificationClient.getClassifiedDocument(inputFile, null).getAllClassifications();

	FileWriter fileWriter = new FileWriter(outputFile);
	for (String rulebaseClass: classificationScores.keySet()) {
		fileWriter.write(rulebaseClass + "\r\n");
		for (ClassificationScore classificationScore: classificationScores.get(rulebaseClass)) {
			fileWriter.write(classificationScore.getName() + ":" + classificationScore.getScore() + "\r\n");
		}
	}
	fileWriter.close();
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:16,代码来源:DirectoryClassifier.java

示例12: initWriters

import java.io.FileWriter; //导入方法依赖的package包/类
private void initWriters() throws IOException {

        schemaFileWriter = new FileWriter(this.hbaseMetaFile);
        sampleFileWriter = new FileWriter(this.hbaseSampleFile);
        //if file exist and clear its content
        schemaFileWriter.write("");
        sampleFileWriter.write("");
    }
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:9,代码来源:HBaseMetaExtractor.java

示例13: createConfigs

import java.io.FileWriter; //导入方法依赖的package包/类
public static void createConfigs(File configFile)
{
	
	ConfigData configData = new ConfigData();
	configData.coolqDir = "./coolq";
	configData.qqBotPort = 11235;
	configData.qqBotNumber = "10000";
	configData.telegramBotToken = "";
	GroupsPairs sample = new GroupsPairs();
	sample.qqGroup = 10000;
	sample.telegramGroup = -1;
	configData.groupsPairs = new ArrayList<GroupsPairs>();
	configData.groupsPairs.add(sample);
	configData.proxyConfig = new ProxyConfig();
	configData.proxyConfig.enableProxy = false;
	configData.proxyConfig.proxyType = "SOCKS";
	configData.proxyConfig.proxyHost = "127.0.0.1";
	configData.proxyConfig.proxyPort = 1080;
	configData.enabledPlugins = new ArrayList<String>();
	configData.enabledPlugins.add("plugins.Transport");
	
	Gson gson = new GsonBuilder().setPrettyPrinting().create();
	String JSONString = gson.toJson(configData);
	
	try
	{
		FileWriter out = new FileWriter(configFile.toString());
		out.write(JSONString);
		out.close();
	}
	catch(IOException e)
	{
		e.printStackTrace();
	}
}
 
开发者ID:XiLingHost,项目名称:tg-qq-trans,代码行数:36,代码来源:CreateConfigs.java

示例14: ExportPepPSMCSV

import java.io.FileWriter; //导入方法依赖的package包/类
private void ExportPepPSMCSV(String folder) throws IOException {
    if (folder == null | "".equals(folder)) {
        folder = FilenameUtils.getFullPath(mzXMLFileName);
    }
    Logger.getRootLogger().info("Writing PSM result to file:" + folder + FilenameUtils.getBaseName(mzXMLFileName) + "_PSMs.csv...");
    FileWriter writer = new FileWriter(folder + FilenameUtils.getBaseName(mzXMLFileName) + "_PSMs.csv");
    writer.write("SpecID,Sequence,ModSeq,TPPModSeq,Modification,Charge,mz,NeutralPepMass,ObservedMass,RT,AdjustedRT,Rank,ScanNo,PreAA,NextAA,MissedCleavage,ExpectValue,MassError,Prob,Rawname,ParentPepIndex,MS1Quant\n");
    for (PepIonID pepion : PepIonList.values()) {
        for (PSM psm : pepion.GetPSMList()) {
            writer.write(psm.SpecNumber + "," + psm.Sequence + "," + psm.ModSeq + "," + psm.TPPModSeq + "," + psm.GetModificationString() + "," + psm.Charge + "," + psm.ObserPrecursorMz() + "," + psm.NeutralPepMass + "," + psm.ObserPrecursorMass + "," + psm.RetentionTime + "," + psm.NeighborMaxRetentionTime + "," + psm.Rank + "," + psm.ScanNo + "," + psm.PreAA + "," + psm.NextAA + "," + psm.MissedCleavage + "," + psm.expect + "," + psm.MassError + "," + psm.Probability + "," + psm.RawDataName + "," + pepion.Index + "," + pepion.GetMS1() + "\n");
        }
    }
    writer.close();
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:15,代码来源:LCMSID.java

示例15: saveFile

import java.io.FileWriter; //导入方法依赖的package包/类
private static void saveFile(File file, List<String> lines) throws IOException
{
    FileWriter writer = new FileWriter(file);
    for (String str : lines)
    {
        writer.write(str);
        writer.write("\n");
    }
    writer.close();
}
 
开发者ID:ObsidianSuite,项目名称:ObsidianSuite,代码行数:11,代码来源:Main.java


注:本文中的java.io.FileWriter.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。