當前位置: 首頁>>代碼示例>>Java>>正文


Java FileReader類代碼示例

本文整理匯總了Java中java.io.FileReader的典型用法代碼示例。如果您正苦於以下問題:Java FileReader類的具體用法?Java FileReader怎麽用?Java FileReader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FileReader類屬於java.io包,在下文中一共展示了FileReader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import java.io.FileReader; //導入依賴的package包/類
private void init(PaySim paysim){
	this.paysim = paysim;
	try {
		File f = new File(this.paysim.getTransferMaxPath());
		FileReader reader = new FileReader(f);
		BufferedReader bufReader = new BufferedReader(reader);
		String line = "";
		
		while((line = bufReader.readLine()) != null){
			this.fileContents.add(line);
		}
		bufReader.close();
	} catch (Exception e) {
		e.printStackTrace();
	}
	initMax(this.fileContents);
	this.multiplier = this.paysim.getMultiplier();
	
}
 
開發者ID:EdgarLopezPhD,項目名稱:PaySim,代碼行數:20,代碼來源:TransferMaxHandler.java

示例2: readJSON

import java.io.FileReader; //導入依賴的package包/類
public String readJSON() {

        try {
            Object obj = parser.parse(new FileReader(jsonFile));
            JSONObject jsonObject = (JSONObject) obj;
            jsonString = JSONWriter.getJSONString(jsonObject);
        } catch (IOException | ParseException ex) {
            Logger.getLogger(ParseJSON.class.getName()).log(Level.SEVERE, null, ex);
        }
        return jsonString;
    }
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:12,代碼來源:ParseJSON.java

示例3: loadCmdFile

import java.io.FileReader; //導入依賴的package包/類
private static void loadCmdFile(String name, List<String> args)
    throws IOException
{
    Reader r = new BufferedReader(new FileReader(name));
    StreamTokenizer st = new StreamTokenizer(r);
    st.resetSyntax();
    st.wordChars(' ', 255);
    st.whitespaceChars(0, ' ');
    st.commentChar('#');
    st.quoteChar('"');
    st.quoteChar('\'');
    while (st.nextToken() != StreamTokenizer.TT_EOF) {
        args.add(st.sval);
    }
    r.close();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:17,代碼來源:CommandLine.java

示例4: loadCmdFile

import java.io.FileReader; //導入依賴的package包/類
private static void loadCmdFile(String name, List args)
    throws IOException
{
    Reader r = new BufferedReader(new FileReader(name));
    StreamTokenizer st = new StreamTokenizer(r);
    st.resetSyntax();
    st.wordChars(' ', 255);
    st.whitespaceChars(0, ' ');
    st.commentChar('#');
    st.quoteChar('"');
    st.quoteChar('\'');
    while (st.nextToken() != st.TT_EOF) {
        args.add(st.sval);
    }
    r.close();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:17,代碼來源:CommandLine.java

示例5: loadOptions

import java.io.FileReader; //導入依賴的package包/類
public static String loadOptions(FileReader fr, String filename) {
    LineNumberReader lnr = new LineNumberReader(fr);
    Group.restoreAllDefaults();
    String line;
    try {
        while ((line = lnr.readLine()) != null) {
            String reason = Group.root.setOption(line);
            if (reason != null) {
                System.err.println("Option "+line+
                                   " at line "+lnr.getLineNumber()+
                                   " ignored: "+reason);
            }
        }
    } catch (IOException e) {
        Group.restoreAllDefaults();
        return ("IO Error reading "+filename+
                " at line "+lnr.getLineNumber());
    }
    return null;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:J2DBench.java

示例6: getResultsTXT

import java.io.FileReader; //導入依賴的package包/類
public static List<ResultList> getResultsTXT(File f, Map<String, MassBank> dbFiles) throws Exception{
	List<ResultList> results=new ArrayList<ResultList>();

	BufferedReader br=new BufferedReader(new FileReader(f));
	String line;
	ResultList rl=null;
	while((line=br.readLine())!=null){
		if(line.startsWith("query")){
			rl=new ResultList();
			results.add(rl);
			Query q=new Query(line.split("\t")[1]);				
			q.massbank=dbFiles.get(q.queryID);
			rl.query=q;
		}else if(line.startsWith("result")){
			Result r=new Result(line.split("\t"));
			r.massbank=dbFiles.get(r.resultID);
			rl.results.add(r);
			r.isTrueMatch=rl.query.massbank.inchi.equals(r.massbank.inchi);
		}
	}
	br.close();


	return results;
}
 
開發者ID:boecker-lab,項目名稱:passatuto,代碼行數:26,代碼來源:ResultList.java

示例7: getPUID

import java.io.FileReader; //導入依賴的package包/類
/**
 * Utility method used to obtain the name of an user based on an uid
 */
private final String getPUID(final String uid) {
    if (pids.containsKey(uid))
        return pids.get(uid);
    final String pat = "([\\S&&[^:]]+):[\\S&&[^:]]+:" + uid + ":";
    final Pattern pattern = PatternUtil.getPattern("uid_" + uid, pat);
    try {
        BufferedReader in = new BufferedReader(new FileReader("/etc/passwd"));
        String line;
        while ((line = in.readLine()) != null) {
            final Matcher matcher = pattern.matcher(line);
            if (matcher.find()) {
                final String puid = matcher.group(1);
                pids.put(uid, puid);
                return puid;
            }
        }
        in.close();
    } catch (Throwable t) {
    }
    pids.put(uid, "UNKNOWN");
    return "UNKNOWN";
}
 
開發者ID:fast-data-transfer,項目名稱:fdt,代碼行數:26,代碼來源:Netstat.java

示例8: readFileToString

import java.io.FileReader; //導入依賴的package包/類
private static String readFileToString(String filePath) {
	StringBuilder fileData = new StringBuilder(1000);
	try {
		BufferedReader reader = new BufferedReader(new FileReader(filePath));

		char[] buf = new char[10];
		int numRead = 0;
		while ((numRead = reader.read(buf)) != -1) {
			String readData = String.valueOf(buf, 0, numRead);
			fileData.append(readData);
			buf = new char[1024];
		}
		reader.close();
	}
	catch(IOException e) {
		e.printStackTrace();
	}
	return fileData.toString();	
}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:20,代碼來源:JavaSourceParser.java

示例9: convertFiles

import java.io.FileReader; //導入依賴的package包/類
public static void convertFiles(OutputStream output, File[] files) throws IOException {
  Context context = new Context();
  context.appender = new OutputStreamAppender(output);
  for (File file : files) {
    context.currentMember = null;
    BufferedReader reader = new BufferedReader(new FileReader(file));
    try {
      String line;
      while ((line = reader.readLine()) != null) {
        for (Test test : tests) {
          if (test.apply(context, line)) {
            // go to the next line
            break;
          }
        }
      }
    } finally {
      reader.close();
    }
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:22,代碼來源:GemfireLogConverter.java

示例10: onEnable

import java.io.FileReader; //導入依賴的package包/類
@Override
public void onEnable() {
	try {
		uuid_map = new HashMap<String, UUID>();
		getConfig().options().copyDefaults(true);
		saveConfig();
		
		initializeLocal();
		registerEvents();
		registerCommands();
		
		if(uuidFile.exists()) {
			BufferedReader reader = new BufferedReader(new FileReader(uuidFile));
			byte[] bytes = reader.readLine().getBytes(Charsets.UTF_8);
			uuid_map = Serializer.<Map<String, UUID>>deserializeBase64(bytes);
			reader.close();
		} else {
			uuidFile.createNewFile();
		}
	} catch (Exception | Error e) {
		getLogger().log(Level.WARNING, e.getMessage(), e);
	}
}
 
開發者ID:ramidzkh,項目名稱:Bssentials-Reloaded,代碼行數:24,代碼來源:Bssentials.java

示例11: FileDataSet

import java.io.FileReader; //導入依賴的package包/類
/**
 * Creates a new instance of a data set, stored in a file. When this object
 * is initialized, the file is read into memory.
 *
 * @param datafile The file containing the data set
 * @throws java.io.IOException when a I/O error is found
 * @throws java.lang.ArrayIndexOutOfBoundsException when the file has not
 * consistent number of columns
 * @throws java.lang.NumberFormatException when the numbers inside the file
 * are not parsable
 */
public FileDataSet(File datafile) throws IOException, NumberFormatException, ArrayIndexOutOfBoundsException {
    super(true);

    BufferedReader in = new BufferedReader(new FileReader(datafile));
    String line;
    List<String> data;
    while ((line = in.readLine()) != null && (!line.equals(""))) {
        line = line.trim();
        if (!line.startsWith("#")) {
            data = new ArrayList<String>();
            StringTokenizer tk = new StringTokenizer(line);
            while (tk.hasMoreTokens())
                data.add(tk.nextToken());
            add(data);
        }
    }
}
 
開發者ID:teras,項目名稱:JavaPlot,代碼行數:29,代碼來源:FileDataSet.java

示例12: demoToCreateWriteAndReadFromFile

import java.io.FileReader; //導入依賴的package包/類
public void demoToCreateWriteAndReadFromFile() throws IOException {
    File file = new File("project.txt");
    file.createNewFile();

    FileWriter fileWriter = new FileWriter(file);
    fileWriter.write ("Hugo Boss \n Gucci \n Tommy Hilfiger \n Armani \n Salvatore \n Dolce & Gabbana \n");
    fileWriter.flush();
    fileWriter.close();

    FileReader fileReader = new FileReader(file);
    char[] charArrays = new char[100];
    fileReader.read(charArrays);

    for (char charArray : charArrays) {
        System.out.println(charArray);
        fileReader.close();
    }
}
 
開發者ID:cyber-coders-j2017a,項目名稱:modern.core.java.repo,代碼行數:19,代碼來源:Geography.java

示例13: loadBlacklist

import java.io.FileReader; //導入依賴的package包/類
private  java.util.HashMap loadBlacklist()
{
    java.util.HashMap<String,String> map = new java.util.HashMap<String,String>();
    try {
        java.io.BufferedReader input = new java.io.BufferedReader( new java.io.FileReader( BLACKLISTFILE ) );
        java.lang.String line = "";
        while ((line = input.readLine()) != null) {
            if (line.length() > 7) {
                map.put( line, line );
            }
        }
        input.close();
    } catch ( java.io.IOException e ) {
        System.out.println( "File is not found" );
    }
    return map;
}
 
開發者ID:terdel-ninja,項目名稱:REH2017Anthony,代碼行數:18,代碼來源:GPMSPasswordValidation.java

示例14: listOfProbs

import java.io.FileReader; //導入依賴的package包/類
private ArrayList<String> listOfProbs(){
	ArrayList<String> allContents = new ArrayList<String>();
	File f = new File(transferFreqMod);
	try {
		BufferedReader reader = new BufferedReader(new FileReader(f));
		String line = "";
		while((line = reader.readLine()) != null){
			allContents.add(line);
		}
		reader.close();
		
	} catch (Exception e) {			
		e.printStackTrace();
	}
	return allContents;
}
 
開發者ID:EdgarLopezPhD,項目名稱:PaySim,代碼行數:17,代碼來源:PaySim.java

示例15: lerArquivo

import java.io.FileReader; //導入依賴的package包/類
public static byte[] lerArquivo(File arquivo) throws Exception {
    byte[] bytes;
    try (FileReader arq = new FileReader(arquivo)) {
        
        BufferedReader lerArq = new BufferedReader(arq);
        String linha = lerArq.readLine();
        String conteudo = linha;
        
        while (linha != null) {
            linha = lerArq.readLine(); // lê da segunda até a última linha
            
            if (linha != null){
                conteudo += linha;
            }
        }   
        
        bytes = conteudo.getBytes();
    }
    
    return bytes;
}
 
開發者ID:Ronneesley,項目名稱:redesocial,代碼行數:22,代碼來源:Utilitarios.java


注:本文中的java.io.FileReader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。