0

ファイルのテキスト全体を読み取り、特定の区切り記号に従って分割したいと考えています。Javaでどうすればできますか?

4

2 に答える 2

2
try{
  // Open the file
  FileInputStream fstream = new FileInputStream("textfile.txt");
  // Get the object of DataInputStream
  DataInputStream in = new DataInputStream(fstream);
  BufferedReader br = new BufferedReader(new InputStreamReader(in));
  String strLine;
  //Read File Line By Line
  while ((strLine = br.readLine()) != null)   {
  // split the line on your splitter(s)
     String[] splitted = strLine.split("-"); // here - is used as the delimiter
  }
  //Close the input stream
  in.close();
    }catch (Exception e){//Catch exception if any
  System.err.println("Error: " + e.getMessage());
  }
于 2012-12-08T07:21:50.130 に答える
0

内容を読む。分割のために各行/単語またはフレーズをチェックする区切り文字を選択します。スイッチケースをセットアップします。スイッチケースに基づいて見つけたコンテンツは何でも、アクションを実行できます。さまざまなケースのさまざまなテキスト ファイルに書き込むことができるとします。

于 2012-12-08T07:09:59.363 に答える