public static void main(String[] args) {
創(chuàng)新互聯(lián)建站是一家專業(yè)從事網(wǎng)站設(shè)計制作、做網(wǎng)站的網(wǎng)絡(luò)公司。作為專業(yè)網(wǎng)站設(shè)計公司,創(chuàng)新互聯(lián)建站依托的技術(shù)實(shí)力、以及多年的網(wǎng)站運(yùn)營經(jīng)驗(yàn),為您提供專業(yè)的成都網(wǎng)站建設(shè)、成都全網(wǎng)營銷推廣及網(wǎng)站設(shè)計開發(fā)服務(wù)!
// TODO 自動生成的方法存根
Scanner sc = new Scanner(System.in);
System.out.println("請輸入歌詞:");
String s = sc.nextLine();
String[] x = s.split(" ");
for(int i = 0;ix.length;i++){
System.out.println(x[i]);
}
}
把歌詞存在一個叫 geci.txt 的文本中 放在D盤根目錄
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class SaveSong {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
BufferedReader br = null;
String lineContent = "";
String[] s = new String[100];
int i = 0;
try {
br = new BufferedReader(new FileReader("D:\\geci.txt"));
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
while ((lineContent = br.readLine()) != null) {
System.out.println(lineContent);
s[i]= lineContent;
i++;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
package xuan;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.Buffer;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
public class mp3 {
public static void cutMusic() throws IOException{
File file=new File("E:\\薛之謙 - 那是你離開了北京的生活.flac");
File file2=new File("E:\\music");
FileInputStream fis =new FileInputStream(file);
FileOutputStream fos=null;
//if(file2.exists()!=true) {
// file2.mkdirs();
//}
int len=0;
int x=0;
int y=1020*1024;
byte [] one=new byte[y];
if(file.length()%y!=0) {
x=(int)(file.length()/y+1);
}else if(file.length()%y==0) {
x=(int)(file.length()/y);
}
for(int i=1;i=x;i++) {
len=fis.read(one);
fos=new FileOutputStream (new File(file2,i+".flac"));
fos.write(one,0,len);
}
fis.close();
fos.close();
}
public static void mergeMusic()throws IOException{
File file=new File("E:\\merge.flac");
File file2=new File("E:\\music");
// if(file.exists()!=true) {
// file.createNewFile();
// }
File[]f=file2.listFiles();
FileInputStream fis=null;
FileOutputStream fos=new FileOutputStream(file);
BufferedOutputStream bos =new BufferedOutputStream(fos,1024*1024);
int len=0;
for(int i=0;if.length;i++) {
fis =new FileInputStream(f[i]);
BufferedInputStream bis =new BufferedInputStream(fis,1024*1024);
while((len=bis.read())!=-1) {
bos.write(len);
}
fos.flush();
fis.close();
}
bos.close();
fos.close();
}
public static void main(String[] args) throws IOException{
cutMusic();
mergeMusic();
// TODO Auto-generated method stub
}
}