當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。