filewriter

    0熱度

    3回答

    我正在處理需要從表中獲取記錄並將其寫入平面文件(如txt)的項目。所以我使用Java IO api中的BufferedWriter來做到這一點。但不幸的是,文件似乎沒有被寫入。 這裏就是我想: public class PrintConnectionStatistics { public static void main(String[] args) { String us

    2熱度

    1回答

    我有這段代碼,我的目標是刪除單詞「the」。所以輸出結果如下所示。 Blockquote 水是潮溼的。男人很生氣。牀很溫暖。 我很難搞清楚該怎麼做,我試過使用replaceALL,但它不起作用。輸出將被寫入文本文件。任何幫助都可以。 import java.io.File; import java.io.FileReader; import java.io.FileWriter; impor

    0熱度

    2回答

    我正在爲我的java類寫入一個方法。它看起來像這樣至今: String file_name; String line; void addLine(file_name, line){ int line_number; try { FileWriter writer = new FileWriter(file_name, true);

    0熱度

    1回答

    我想通過Java編輯現有的文件,在行的每個第4個字符後面都有一個換行符,後跟一個空格。所以下面是期望值。 File Content ------------ abcdef gh ijklmn Expected output -------------- abcd ef gh ijkl mn 下面是已嘗試的代碼,但是這將全部寫入一行。 import java.io.Buf

    -1熱度

    2回答

    CSV文件我有一個CSV日誌文件,它包含很多這樣的行: 2016-06-21 12:00:00,000 : helloworld: header1=2;header2=6;header=0 我想他們寫入到一個新的CSV文件。 public void readLogFile() throws Exception { String currentLine = ""; Stri

    -1熱度

    1回答

    作爲一名業餘java學習者,我嘗試了java文件和I/O方法的不同組合,因爲我嘗試了這種代碼,我想通過我的代碼打印任何我輸入的文件tom.txt(我明白我想要什麼可以很容易地通過使用其他方法)來完成,我的代碼是這樣的: import java.io.*; public class Dhoom3 { public static void main(String[] args) throws I

    -4熱度

    1回答

    在我的代碼,我的方法之一說: this.write("stuff") 和write方法是 public void write(String text) throws IOException { FileWriter writer = new FileWriter(path, true); PrintWriter printer = new PrintWriter(writ

    1熱度

    1回答

    我設法將wav文件轉換爲mp3文件。 但是,當我的應用程序正在運行,它只會凍結VLC媒體播放器(不良文件描述符) 當我關閉我的應用程序時,它會發揮得很好。 public void ConvertWavToMp3(string filename) { LameMP3FileWriter mpFileWriter; if (File.Exists(Path.Combi

    -3熱度

    1回答

    我知道這可能會向下投票這個使用.close()是困擾我很多 我已經閱讀.close所有文章()方法類似 explain the close() method in Java in Layman's terms Why do I need to call a close() or shutdown() method? the usage of close() method(Java Beginner

    4熱度

    2回答

    我的腳本需要從JSON文件讀取和寫入,這沒有問題。 我在本地複製文件,編輯對象並將它們作爲備份寫入文件 但是,當我用ctrl + c關閉腳本並檢查我的文件時,它具有[object,object]而不是應該在那裏的實際對象。 這並不是每次都發生,但是很煩人,因爲我的腳本依賴於這個文件。 任何想法如何防止像關閉閱讀器一樣安全嗎? 已經嘗試在寫入之前檢查類型,但似乎沒有多大幫助。 function wr