当前位置: 首页>>代码示例>>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;未经允许,请勿转载。